Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
erp5
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
alecs_myu
erp5
Commits
119f5592
Commit
119f5592
authored
Mar 27, 2013
by
Tatuya Kamada
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Unit Test: Check a case using both Full and Partial Inventory.
parent
0f33f18c
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
121 additions
and
9 deletions
+121
-9
product/ERP5/tests/testInventory.py
product/ERP5/tests/testInventory.py
+121
-9
No files found.
product/ERP5/tests/testInventory.py
View file @
119f5592
...
@@ -201,16 +201,20 @@ class TestInventory(TestOrderMixin, ERP5TypeTestCase):
...
@@ -201,16 +201,20 @@ class TestInventory(TestOrderMixin, ERP5TypeTestCase):
inventory_list
.
append
(
inventory
)
inventory_list
.
append
(
inventory
)
sequence
.
edit
(
inventory_list
=
inventory_list
)
sequence
.
edit
(
inventory_list
=
inventory_list
)
def
createInventory
(
self
,
sequence
=
None
,
full
=
False
):
def
createInventory
(
self
,
sequence
=
None
,
full
=
False
,
**
kw
):
"""
"""
"""
"""
portal
=
self
.
getPortal
()
portal
=
self
.
getPortal
()
if
kw
.
get
(
'start_date'
,
None
)
is
not
None
:
start_date
=
kw
[
'start_date'
]
else
:
start_date
=
DateTime
()
+
1
inventory_list
=
sequence
.
get
(
'inventory_list'
,[])
inventory_list
=
sequence
.
get
(
'inventory_list'
,[])
inventory_module
=
portal
.
getDefaultModule
(
portal_type
=
self
.
inventory_portal_type
)
inventory_module
=
portal
.
getDefaultModule
(
portal_type
=
self
.
inventory_portal_type
)
inventory
=
inventory_module
.
newContent
(
portal_type
=
self
.
inventory_portal_type
)
inventory
=
inventory_module
.
newContent
(
portal_type
=
self
.
inventory_portal_type
)
inventory
.
edit
(
destination_value
=
sequence
.
get
(
'node'
),
inventory
.
edit
(
destination_value
=
sequence
.
get
(
'node'
),
destination_section_value
=
sequence
.
get
(
'section'
),
destination_section_value
=
sequence
.
get
(
'section'
),
start_date
=
DateTime
()
+
1
,
start_date
=
start_date
,
full_inventory
=
full
,
full_inventory
=
full
,
)
)
inventory_list
.
append
(
inventory
)
inventory_list
.
append
(
inventory
)
...
@@ -2191,11 +2195,14 @@ class TestInventory(TestOrderMixin, ERP5TypeTestCase):
...
@@ -2191,11 +2195,14 @@ class TestInventory(TestOrderMixin, ERP5TypeTestCase):
sequence_list
=
None
,
**
kw
):
sequence_list
=
None
,
**
kw
):
""" Create Full Inventory at the date' """
""" Create Full Inventory at the date' """
inventory_list
=
sequence
.
get
(
'inventory_list'
,[])
inventory_list
=
sequence
.
get
(
'inventory_list'
,[])
self
.
assertEquals
(
len
(
inventory_list
),
0
)
if
kw
.
get
(
'start_date'
,
None
)
is
not
None
:
if
kw
.
get
(
'start_date'
,
None
)
is
not
None
:
start_date
=
kw
[
'start_date'
]
start_date
=
kw
[
'start_date'
]
else
:
else
:
start_date
=
'2013/03/12 00:00:00 GMT+9'
start_date
=
'2013/03/12 00:00:00 GMT+9'
if
kw
.
get
(
'resource_value'
,
None
)
is
not
None
:
resource_value
=
kw
[
'resource_value'
]
else
:
resource_value
=
sequence
.
get
(
'resource'
)
inventory
=
self
.
createInventory
(
sequence
=
sequence
)
inventory
=
self
.
createInventory
(
sequence
=
sequence
)
inventory
.
edit
(
full_inventory
=
True
,
inventory
.
edit
(
full_inventory
=
True
,
destination_section_value
=
sequence
.
get
(
'section'
),
destination_section_value
=
sequence
.
get
(
'section'
),
...
@@ -2203,7 +2210,7 @@ class TestInventory(TestOrderMixin, ERP5TypeTestCase):
...
@@ -2203,7 +2210,7 @@ class TestInventory(TestOrderMixin, ERP5TypeTestCase):
start_date
=
start_date
)
start_date
=
start_date
)
inventory_line
=
inventory
.
newContent
(
inventory_line
=
inventory
.
newContent
(
portal_type
=
self
.
inventory_line_portal_type
,
portal_type
=
self
.
inventory_line_portal_type
,
resource_value
=
sequence
.
get
(
"resource"
)
,
resource_value
=
resource_value
,
inventory
=
100
)
inventory
=
100
)
inventory
.
deliver
()
inventory
.
deliver
()
inventory_list
.
append
(
inventory
)
inventory_list
.
append
(
inventory
)
...
@@ -2212,11 +2219,13 @@ class TestInventory(TestOrderMixin, ERP5TypeTestCase):
...
@@ -2212,11 +2219,13 @@ class TestInventory(TestOrderMixin, ERP5TypeTestCase):
def
stepCreateFullInventoryAtTheDate1
(
self
,
sequence
=
None
,
def
stepCreateFullInventoryAtTheDate1
(
self
,
sequence
=
None
,
sequence_list
=
None
,
**
kw
):
sequence_list
=
None
,
**
kw
):
if
getattr
(
self
,
'inventory_start_date_1'
,
None
)
is
None
:
if
getattr
(
self
,
'
full_
inventory_start_date_1'
,
None
)
is
None
:
raise
UnboundLocalError
(
'Please assign self.inventory_start_date_1 '
raise
UnboundLocalError
(
'Please assign self.
full_
inventory_start_date_1 '
'in your test method'
)
'in your test method'
)
self
.
stepCreateFullInventoryAtTheDate
(
params
=
dict
(
start_date
=
self
.
full_inventory_start_date_1
)
sequence
,
sequence_list
,
start_date
=
self
.
inventory_start_date_1
)
if
getattr
(
self
,
'full_inventory_resource_1'
,
None
)
is
not
None
:
params
[
'resource_value'
]
=
sequence
.
get
(
self
.
full_inventory_resource_1
)
self
.
stepCreateFullInventoryAtTheDate
(
sequence
,
sequence_list
,
**
params
)
def
stepCheckMultipleSectionAndFullInventory
(
self
,
sequence
=
None
,
def
stepCheckMultipleSectionAndFullInventory
(
self
,
sequence
=
None
,
sequence_list
=
None
,
**
kw
):
sequence_list
=
None
,
**
kw
):
...
@@ -2346,6 +2355,69 @@ class TestInventory(TestOrderMixin, ERP5TypeTestCase):
...
@@ -2346,6 +2355,69 @@ class TestInventory(TestOrderMixin, ERP5TypeTestCase):
section_uid
=
section
.
getUid
(),
section_uid
=
section
.
getUid
(),
node_uid
=
node
.
getUid
())
node_uid
=
node
.
getUid
())
def
stepCreateInventoryAtTheDate
(
self
,
sequence
=
None
,
sequence_list
=
None
,
**
kw
):
""" Create Inventory at the date with some flexible variables """
inventory_quantity
=
kw
[
'inventory'
]
if
'inventory'
in
kw
else
100
start_date
=
kw
[
'start_date'
]
if
'start_date'
in
kw
else
None
if
'resource_value'
in
kw
:
resource_value
=
kw
[
'resource_value'
]
else
:
resource_value
=
sequence
.
get
(
'second_resource'
)
inventory
=
self
.
createInventory
(
sequence
=
sequence
,
full
=
False
,
start_date
=
start_date
)
inventory_list
=
sequence
.
get
(
'inventory_list'
,[])
inventory_line
=
inventory
.
newContent
(
portal_type
=
self
.
inventory_line_portal_type
,
resource_value
=
resource_value
,
inventory
=
inventory_quantity
)
inventory
.
deliver
()
inventory_list
.
append
(
inventory
)
sequence
.
edit
(
inventory_list
=
inventory_list
)
def
stepCreateInventoryAtTheDate1
(
self
,
sequence
=
None
,
sequence_list
=
None
,
**
kw
):
""" Create Inventory at the date:'self.inventory_start_date_1'
with some flexible variables """
if
getattr
(
self
,
'inventory_start_date_1'
,
None
)
is
None
:
raise
UnboundLocalError
(
'Please assign self.inventory_start_date_1 '
'in your test method'
)
params
=
dict
(
start_date
=
self
.
inventory_start_date_1
)
if
getattr
(
self
,
'inventory_1'
,
None
)
is
not
None
:
params
[
'inventory'
]
=
self
.
inventory_1
if
getattr
(
self
,
'inventory_resource_1'
,
None
)
is
not
None
:
params
[
'resource_value'
]
=
sequence
.
get
(
self
.
inventory_resource_1
)
self
.
stepCreateInventoryAtTheDate
(
sequence
,
sequence_list
,
**
params
)
def
stepCreateInventoryAtTheDate2
(
self
,
sequence
=
None
,
sequence_list
=
None
,
**
kw
):
""" Create Inventory at the date:'self.inventory_start_date_2'
with some flexible variables """
if
getattr
(
self
,
'inventory_start_date_2'
,
None
)
is
None
:
raise
UnboundLocalError
(
'Please assign self.inventory_start_date_2 '
'in your test method'
)
params
=
dict
(
start_date
=
self
.
inventory_start_date_2
)
if
getattr
(
self
,
'inventory_2'
,
None
)
is
not
None
:
params
[
'inventory'
]
=
self
.
inventory_2
if
getattr
(
self
,
'inventory_resource_2'
,
None
)
is
not
None
:
params
[
'resource_value'
]
=
sequence
.
get
(
self
.
inventory_resource_2
)
self
.
stepCreateInventoryAtTheDate
(
sequence
,
sequence_list
,
**
params
)
def
stepCheckUseBothFullAndPartialInventory
(
self
,
sequence
=
None
,
sequence_list
=
None
,
**
kw
):
""" Check a case Using both Full and Normal Inventory"""
resource_value
=
sequence
.
get
(
'second_resource'
)
node_value
=
sequence
.
get
(
'node'
)
section_value
=
sequence
.
get
(
'section'
)
self
.
_testGetInventory
(
expected
=
3
,
section_uid
=
section_value
.
getUid
(),
node_uid
=
node_value
.
getUid
(),
resource_uid
=
resource_value
.
getUid
())
self
.
_testGetInventory
(
expected
=
3
,
resource_uid
=
resource_value
.
getUid
(),
optimise__
=
False
)
def
test_01_getInventory
(
self
,
quiet
=
0
,
run
=
run_all_test
):
def
test_01_getInventory
(
self
,
quiet
=
0
,
run
=
run_all_test
):
"""
"""
...
@@ -2699,7 +2771,7 @@ class TestInventory(TestOrderMixin, ERP5TypeTestCase):
...
@@ -2699,7 +2771,7 @@ class TestInventory(TestOrderMixin, ERP5TypeTestCase):
"""
"""
if
not
run
:
return
if
not
run
:
return
self
.
inventory_start_date_1
=
'2013/03/15 00:00:00 GMT+9'
self
.
full_
inventory_start_date_1
=
'2013/03/15 00:00:00 GMT+9'
self
.
start_date_1
=
'2013/02/10 00:00:00 GMT+9'
self
.
start_date_1
=
'2013/02/10 00:00:00 GMT+9'
self
.
start_date_2
=
'2013/02/01 00:00:00 GMT+9'
self
.
start_date_2
=
'2013/02/01 00:00:00 GMT+9'
sequence_list
=
SequenceList
()
sequence_list
=
SequenceList
()
...
@@ -2724,6 +2796,46 @@ class TestInventory(TestOrderMixin, ERP5TypeTestCase):
...
@@ -2724,6 +2796,46 @@ class TestInventory(TestOrderMixin, ERP5TypeTestCase):
sequence_list
.
play
(
self
)
sequence_list
.
play
(
self
)
def
test_12_UseBothFullAndPartialInventory
(
self
,
quiet
=
0
,
run
=
run_all_test
):
"""
Make sure a case Using both Full and Partial Inventories:
The case is:
1) inventory: 2013/01/10, section=A, node=B, resource=X, quantity=3
2) full inventory: 2013/02/21,section=A, node=B, resource=Y, quantity=100
(there is only *Y*. No X.)
3) inventory: 2013/03/10,section=A, node=B, resource=X, quantity=3
[test]
getInventory(resource=X) should return 3
getInventory(resource=X, optimise__=False) should return 3
"""
if
not
run
:
return
self
.
inventory_start_date_1
=
'2013/01/10 00:00:00 GMT+9'
self
.
full_inventory_start_date_1
=
'2013/01/10 00:00:00 GMT+9'
self
.
inventory_start_date_2
=
'2013/03/10 00:00:00 GMT+9'
self
.
full_inventory_resource_1
=
'resource'
self
.
inventory_resource_1
=
self
.
inventory_resource_2
=
'second_resource'
self
.
inventory_1
=
3
self
.
inventory_2
=
3
sequence_list
=
SequenceList
()
sequence_string
=
'CreateOrganisationsForModule
\
CreateNotVariatedResource
\
CreateNotVariatedSecondResource
\
Tic
\
CreateInventoryAtTheDate1
\
Tic
\
CreateFullInventoryAtTheDate1
\
Tic
\
CreateInventoryAtTheDate2
\
Tic
\
CheckUseBothFullAndPartialInventory
\
'
sequence_list
.
addSequenceString
(
sequence_string
)
sequence_list
.
play
(
self
)
def
test_suite
():
def
test_suite
():
suite
=
unittest
.
TestSuite
()
suite
=
unittest
.
TestSuite
()
suite
.
addTest
(
unittest
.
makeSuite
(
TestInventory
))
suite
.
addTest
(
unittest
.
makeSuite
(
TestInventory
))
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment