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
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Rafael Monnerat
erp5
Commits
d4dce69d
Commit
d4dce69d
authored
Dec 13, 2018
by
Xiaowu Zhang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
testInventory: update test
remove useless test_21 update test_20 with various packing list
parent
cc8672de
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
443 additions
and
395 deletions
+443
-395
product/ERP5/tests/testInventory.py
product/ERP5/tests/testInventory.py
+443
-395
No files found.
product/ERP5/tests/testInventory.py
View file @
d4dce69d
...
@@ -76,7 +76,7 @@ class TestInventory(TestOrderMixin, ERP5TypeTestCase):
...
@@ -76,7 +76,7 @@ class TestInventory(TestOrderMixin, ERP5TypeTestCase):
"""
"""
return
(
'erp5_base'
,
'erp5_pdm'
,
'erp5_simulation'
,
'erp5_trade'
,
return
(
'erp5_base'
,
'erp5_pdm'
,
'erp5_simulation'
,
'erp5_trade'
,
'erp5_configurator_standard_trade_template'
,
'erp5_configurator_standard_trade_template'
,
'erp5_apparel'
,
'erp5_simulation_test'
)
'erp5_apparel'
,
'erp5_simulation_test'
,
'erp5_mrp'
)
def
setUpPreferences
(
self
):
def
setUpPreferences
(
self
):
#create apparel variation preferences
#create apparel variation preferences
...
@@ -1230,21 +1230,6 @@ class TestInventory(TestOrderMixin, ERP5TypeTestCase):
...
@@ -1230,21 +1230,6 @@ class TestInventory(TestOrderMixin, ERP5TypeTestCase):
LOG
(
'TestInventory._testGetInventory'
,
0
,
msg
)
LOG
(
'TestInventory._testGetInventory'
,
0
,
msg
)
LOG
(
'SQL Query was : '
,
0
,
str
(
simulation
.
getInventory
(
src__
=
1
,
**
kw
)))
LOG
(
'SQL Query was : '
,
0
,
str
(
simulation
.
getInventory
(
src__
=
1
,
**
kw
)))
self
.
assertEqual
(
e_inventory
,
a_inventory
,
msg
)
self
.
assertEqual
(
e_inventory
,
a_inventory
,
msg
)
def
_testGetInventoryAssetPrice
(
self
,
expected
,
**
kw
):
"""
Shared testing method
"""
simulation
=
self
.
getPortal
().
portal_simulation
e_inventory
=
expected
LOG
(
'Testing inventory with args :'
,
0
,
kw
)
a_inventory
=
simulation
.
getInventoryAssetPrice
(
**
kw
)
if
e_inventory
!=
a_inventory
:
msg
=
'Inventory differs between expected (%s) and real (%s) price'
\
%
(
repr
(
e_inventory
),
repr
(
a_inventory
))
LOG
(
'TestInventory._testGetInventoryAssetPrice'
,
0
,
msg
)
LOG
(
'SQL Query was : '
,
0
,
str
(
simulation
.
getInventoryAssetPrice
(
src__
=
1
,
**
kw
)))
self
.
assertEqual
(
e_inventory
,
a_inventory
,
msg
)
def
stepTestGetInventoryOnSimulationState
(
self
,
sequence
=
None
,
def
stepTestGetInventoryOnSimulationState
(
self
,
sequence
=
None
,
...
@@ -3550,8 +3535,8 @@ class TestInventory(TestOrderMixin, ERP5TypeTestCase):
...
@@ -3550,8 +3535,8 @@ class TestInventory(TestOrderMixin, ERP5TypeTestCase):
packing_list
=
packing_list_module
.
newContent
(
packing_list
=
packing_list_module
.
newContent
(
portal_type
=
packing_list_portal_type
)
portal_type
=
packing_list_portal_type
)
if
kw
.
get
(
'
star
t_date'
,
None
)
is
not
None
:
if
kw
.
get
(
'
a
t_date'
,
None
)
is
not
None
:
start_date
=
stop_date
=
kw
[
'
star
t_date'
]
start_date
=
stop_date
=
kw
[
'
a
t_date'
]
else
:
else
:
start_date
=
stop_date
=
DateTime
()
-
2
start_date
=
stop_date
=
DateTime
()
-
2
packing_list
.
edit
(
packing_list
.
edit
(
...
@@ -3573,8 +3558,7 @@ class TestInventory(TestOrderMixin, ERP5TypeTestCase):
...
@@ -3573,8 +3558,7 @@ class TestInventory(TestOrderMixin, ERP5TypeTestCase):
price
=
price
price
=
price
)
)
sequence
.
edit
(
packing_list
=
packing_list
)
sequence
.
edit
(
packing_list
=
packing_list
)
return
packing_list_line
def
stepCreateSalePackingListToSectionNodeForFirstResource
(
self
,
sequence
=
None
,
def
stepCreateSalePackingListToSectionNodeForFirstResource
(
self
,
sequence
=
None
,
sequence_list
=
None
,
sequence_list
=
None
,
...
@@ -3707,458 +3691,522 @@ class TestInventory(TestOrderMixin, ERP5TypeTestCase):
...
@@ -3707,458 +3691,522 @@ class TestInventory(TestOrderMixin, ERP5TypeTestCase):
sequence_list
.
addSequenceString
(
sequence_string
)
sequence_list
.
addSequenceString
(
sequence_string
)
sequence_list
.
play
(
self
)
sequence_list
.
play
(
self
)
def
stepCreateIPLForModule
(
self
,
sequence
=
None
,
sequence_list
=
None
,
**
kw
):
def
stepInitialAWarehouseX
(
self
,
sequence
=
None
,
sequence_list
=
None
,
**
kw
):
node
=
sequence
.
get
(
'node'
)
#sale packing list
section
=
sequence
.
get
(
'section'
)
at_date
=
DateTime
(
'2013/02/10 00:00:00 GMT+9'
)
other_node
=
sequence
.
get
(
'other_node'
)
resource
=
sequence
.
get
(
'resource'
)
resource
=
sequence
.
get
(
'resource'
)
packing_list_module
=
self
.
getPortal
().
getDefaultModule
(
A
=
sequence
.
get
(
'section'
)
portal_type
=
'Internal Packing List'
)
X
=
sequence
.
get
(
'node'
)
packing_list
=
packing_list_module
.
newContent
(
mirror_section
=
sequence
.
get
(
'mirror_section'
)
portal_type
=
'Internal Packing List'
)
mirror_node
=
sequence
.
get
(
'mirror_node'
)
start_date
=
stop_date
=
self
.
start_date_1
#same owner but different warehouse
self
.
stepCreatePackingList
(
sequence
=
sequence
,
packing_list
.
edit
(
sequence_list
=
sequence_list
,
specialise
=
self
.
business_process
,
section
=
A
,
source_section_value
=
section
,
node
=
X
,
source_value
=
node
,
mirror_section
=
mirror_section
,
destination_section_value
=
section
,
mirror_node
=
mirror_node
,
destination_value
=
other_node
,
resource
=
resource
,
start_date
=
start_date
,
quantity
=
100
,
stop_date
=
stop_date
,
at_date
=
at_date
,
price_currency
=
self
.
price_currency
packing_list
=
'Sale Packing List'
)
)
sequence
.
edit
(
packing_list
=
packing_list
)
def
stepCreatePackingListLineWithQuantity3
(
self
,
sequence
=
None
,
sequence_list
=
None
,
**
kw
):
packing_list
=
sequence
.
get
(
'packing_list'
)
resource_value
=
sequence
.
get
(
'resource'
)
packing_list_line
=
packing_list
.
newContent
(
portal_type
=
'Internal Packing List Line'
)
packing_list_line
.
edit
(
resource_value
=
resource_value
,
quantity
=
3.
)
def
stepCreatePackingListLineWithQuantity_3
(
self
,
sequence
=
None
,
sequence_list
=
None
,
**
kw
):
packing_list
=
sequence
.
get
(
'packing_list'
)
resource_value
=
sequence
.
get
(
'resource'
)
packing_list_line
=
packing_list
.
newContent
(
portal_type
=
'Internal Packing List Line'
)
packing_list_line
.
edit
(
resource_value
=
resource_value
,
quantity
=
-
3.
)
def
stepCreatePackingListLineWithQuantity30
(
self
,
sequence
=
None
,
sequence_list
=
None
,
**
kw
):
packing_list
=
sequence
.
get
(
'packing_list'
)
resource_value
=
sequence
.
get
(
'resource'
)
packing_list_line
=
packing_list
.
newContent
(
portal_type
=
'Internal Packing List Line'
)
packing_list_line
.
edit
(
resource_value
=
resource_value
,
quantity
=
30.
)
def
stepCreatePackingListLineWithQuantity_30
(
self
,
sequence
=
None
,
sequence_list
=
None
,
**
kw
):
packing_list
=
sequence
.
get
(
'packing_list'
)
resource_value
=
sequence
.
get
(
'resource'
)
packing_list_line
=
packing_list
.
newContent
(
portal_type
=
'Internal Packing List Line'
)
packing_list_line
.
edit
(
resource_value
=
resource_value
,
quantity
=
-
30.
)
def
stepCreatePackingListLineWithQuantity33
(
self
,
sequence
=
None
,
def
stepCreateIPLFromAWarehouseXToAWarehouseYWithQuantity3
(
self
,
sequence
=
None
,
sequence_list
=
None
,
**
kw
):
sequence_list
=
None
,
**
kw
):
A
=
sequence
.
get
(
'section'
)
packing_list
=
sequence
.
get
(
'packing_list'
)
X
=
sequence
.
get
(
'node'
)
resource_value
=
sequence
.
get
(
'resource'
)
Y
=
sequence
.
get
(
'other_node'
)
packing_list_line
=
packing_list
.
newContent
(
portal_type
=
'Internal Packing List Line'
)
packing_list_line
.
edit
(
resource_value
=
resource_value
,
quantity
=
33.
)
def
stepTestMultiCancelInventory
(
self
,
sequence
=
None
,
sequence_list
=
None
,
**
kw
):
resource_value
=
sequence
.
get
(
'resource'
)
node_value
=
sequence
.
get
(
'node'
)
other_node_value
=
sequence
.
get
(
'other_node'
)
section_value
=
sequence
.
get
(
'section'
)
at_date
=
self
.
start_date_1
self
.
_testGetInventory
(
expected
=
67
,
section_uid
=
section_value
.
getUid
(),
node_uid
=
node_value
.
getUid
(),
resource_uid
=
resource_value
.
getUid
(),
at_date
=
at_date
)
self
.
_testGetInventory
(
expected
=
33
,
section_uid
=
section_value
.
getUid
(),
node_uid
=
other_node_value
.
getUid
(),
resource_uid
=
resource_value
.
getUid
(),
at_date
=
at_date
)
def
test_20_InventoryWhenCancelInternalPackingList
(
self
,
quite
=
0
,
run
=
run_all_test
):
"""
When Company A's 33 of product G was shipped from warehouse X
to warehouse Y (ownership is still same, just location change)
in real world, an ERP5 user made many mistakes to enter the above
single fact and in the end he created five IPL(Internal Packing List)
to record the single fact.
IPL1 (quantity is wrong)
start_date 2013/Feb/10
source_section A destination_section A
source X destination Y
resource G quantity 3
simulation_state
IPL2 (Cancellation of IPL1)
start_date 2013/Feb/10
source_section A destination_section A
source X destination Y
resource G quantity -3
simulation_state delivered
IPL3 (He made a mistake again!)
start_date 2013/Feb/10
source_section A destination_section A
source X destination Y
resource H quantity 30
simulation_state delivered
IPL4 (Cancellation of IPL3)
start_date 2013/Feb/10
source_section A destination_section A
source X destination Y
resource H quantity -30
simulation_state delivered
IPL5 (Finally he was able to enter data correctly!)
start_date 2013/Feb/10
source_section A destination_section A
source X destination Y
resource G quantity 33
simulation_state delivered
"""
if
not
run
:
return
self
.
start_date_1
=
'2013/02/10 00:00:00 GMT+9'
sequence_list
=
SequenceList
()
sequence_string
=
'CreateOrganisationsForModule
\
CreateNotVariatedResource
\
Tic
\
CreatePackingListAtTheDate1
\
CreatePackingListLine
\
Tic
\
DeliverPackingList
\
Tic
\
CreateIPLForModule
\
CreatePackingListLineWithQuantity3
\
Tic
\
DeliverPackingList
\
Tic
\
CreateIPLForModule
\
CreatePackingListLineWithQuantity_3
\
Tic
\
DeliverPackingList
\
Tic
\
CreateIPLForModule
\
CreatePackingListLineWithQuantity30
\
Tic
\
DeliverPackingList
\
Tic
\
CreateIPLForModule
\
CreatePackingListLineWithQuantity_30
\
Tic
\
DeliverPackingList
\
Tic
\
CreateIPLForModule
\
CreatePackingListLineWithQuantity33
\
Tic
\
DeliverPackingList
\
Tic
\
TestMultiCancelInventory
\
'
sequence_list
.
addSequenceString
(
sequence_string
)
sequence_list
.
play
(
self
)
def
stepCreateOneMoreSection
(
self
,
sequence
=
None
,
sequence_list
=
None
,
**
kw
):
self
.
stepCreateOrganisation
(
sequence
=
sequence
,
sequence_list
=
sequence_list
,
**
kw
)
one_more_section
=
sequence
.
get
(
'organisation'
)
sequence
.
edit
(
one_more_section
=
one_more_section
)
def
stepCreateSalePackingListToA
(
self
,
sequence
=
None
,
sequence_list
=
None
,
**
kw
):
#A
section
=
sequence
.
get
(
'section'
)
node
=
sequence
.
get
(
'node'
)
resource
=
sequence
.
get
(
'resource'
)
resource
=
sequence
.
get
(
'resource'
)
at_date
=
DateTime
(
'2013/02/11 00:00:00 GMT+9'
)
self
.
stepCreatePackingList
(
sequence
=
sequence
,
self
.
stepCreatePackingList
(
sequence
=
sequence
,
sequence_list
=
sequence_list
,
sequence_list
=
sequence_list
,
section
=
section
,
section
=
A
,
node
=
node
,
node
=
Y
,
resource
=
resource
,
mirror_section
=
A
,
quantity
=
10
,
mirror_node
=
X
,
price
=
100
,
resource
=
resource
,
packing_list
=
'Sale Packing List'
)
quantity
=
3
,
at_date
=
at_date
,
def
stepCreatePurchasePackingListForASecond
(
self
,
sequence
=
None
,
packing_list
=
'Internal Packing List'
)
sequence_list
=
None
,
**
kw
):
#A
def
stepCancelIPLFromAWarehouseXToAWarehouseYWithQuantity3
(
self
,
sequence
=
None
,
sequence_list
=
None
,
**
kw
):
section
=
sequence
.
get
(
'section'
)
A
=
sequence
.
get
(
'section'
)
node
=
sequence
.
get
(
'node'
)
X
=
sequence
.
get
(
'node'
)
Y
=
sequence
.
get
(
'other_node'
)
resource
=
sequence
.
get
(
'resource'
)
resource
=
sequence
.
get
(
'resource'
)
at_date
=
DateTime
(
'2013/02/11 02:00:00 GMT+9'
)
self
.
stepCreatePackingList
(
sequence
=
sequence
,
self
.
stepCreatePackingList
(
sequence
=
sequence
,
sequence_list
=
sequence_list
,
sequence_list
=
sequence_list
,
section
=
section
,
section
=
A
,
node
=
node
,
node
=
X
,
resource
=
resource
,
mirror_section
=
A
,
quantity
=
15
,
mirror_node
=
Y
,
price
=
200
,
resource
=
resource
,
packing_list
=
'Purchase Packing List'
)
quantity
=
3
,
at_date
=
at_date
,
def
stepCreatePurchasePackingListForAThird
(
self
,
sequence
=
None
,
packing_list
=
'Internal Packing List'
)
sequence_list
=
None
,
**
kw
):
#A
def
stepCreateIPLFromAWarehouseXToAWarehouseYWithQuantity30
(
self
,
sequence
=
None
,
sequence_list
=
None
,
**
kw
):
section
=
sequence
.
get
(
'section'
)
A
=
sequence
.
get
(
'section'
)
node
=
sequence
.
get
(
'node'
)
X
=
sequence
.
get
(
'node'
)
Y
=
sequence
.
get
(
'other_node'
)
resource
=
sequence
.
get
(
'resource'
)
resource
=
sequence
.
get
(
'resource'
)
at_date
=
DateTime
(
'2013/02/13 04:00:00 GMT+9'
)
self
.
stepCreatePackingList
(
sequence
=
sequence
,
self
.
stepCreatePackingList
(
sequence
=
sequence
,
sequence_list
=
sequence_list
,
sequence_list
=
sequence_list
,
section
=
section
,
section
=
A
,
node
=
node
,
node
=
Y
,
resource
=
resource
,
mirror_section
=
A
,
quantity
=
20
,
mirror_node
=
X
,
price
=
200
,
resource
=
resource
,
packing_list
=
'Purchase Packing List'
)
quantity
=
30
,
at_date
=
at_date
,
packing_list
=
'Internal Packing List'
)
def
stepCreatePurchasePackingListForB
(
self
,
sequence
=
None
,
def
stepCancelIPLFromAWarehouseXToAWarehouseYWithQuantity30
(
self
,
sequence
=
None
,
sequence_list
=
None
,
**
kw
):
sequence_list
=
None
,
**
kw
):
A
=
sequence
.
get
(
'section'
)
#B
X
=
sequence
.
get
(
'node'
)
section
=
sequence
.
get
(
'other_section'
)
Y
=
sequence
.
get
(
'other_node'
)
node
=
sequence
.
get
(
'other_node'
)
resource
=
sequence
.
get
(
'resource'
)
resource
=
sequence
.
get
(
'resource'
)
at_date
=
DateTime
(
'2013/02/14 05:00:00 GMT+9'
)
self
.
stepCreatePackingList
(
sequence
=
sequence
,
self
.
stepCreatePackingList
(
sequence
=
sequence
,
sequence_list
=
sequence_list
,
sequence_list
=
sequence_list
,
section
=
section
,
section
=
A
,
node
=
node
,
node
=
X
,
resource
=
resource
,
mirror_section
=
A
,
quantity
=
20
,
mirror_node
=
Y
,
price
=
55
,
resource
=
resource
,
packing_list
=
'Purchase Packing List'
)
quantity
=
30
,
at_date
=
at_date
,
def
stepCreateSalePackingListFromAToB
(
self
,
sequence
=
None
,
packing_list
=
'Internal Packing List'
)
def
stepCreateSPLFromAWarehouseXToBWarehouseYWithQuantity30
(
self
,
sequence
=
None
,
sequence_list
=
None
,
**
kw
):
sequence_list
=
None
,
**
kw
):
#B
A
=
sequence
.
get
(
'section'
)
section
=
sequence
.
get
(
'other_section'
)
X
=
sequence
.
get
(
'node'
)
node
=
sequence
.
get
(
'other_node'
)
B
=
sequence
.
get
(
'other_section'
)
Y
=
sequence
.
get
(
'other_node'
)
resource
=
sequence
.
get
(
'resource'
)
resource
=
sequence
.
get
(
'resource'
)
#A
at_date
=
DateTime
(
'2013/02/14 04:00:00 GMT+9'
)
mirror_section
=
sequence
.
get
(
'section'
)
mirror_node
=
sequence
.
get
(
'node'
)
self
.
stepCreatePackingList
(
sequence
=
sequence
,
packing_list_line_a_to_b
=
self
.
stepCreatePackingList
(
sequence
=
sequence
,
sequence_list
=
sequence_list
,
sequence_list
=
sequence_list
,
section
=
section
,
section
=
B
,
node
=
node
,
node
=
Y
,
mirror_section
=
mirror_section
,
mirror_section
=
A
,
mirror_node
=
mirror_node
,
mirror_node
=
X
,
resource
=
resource
,
resource
=
resource
,
quantity
=
30
,
quantity
=
30
,
at_date
=
at_date
,
packing_list
=
'Sale Packing List'
)
packing_list
=
'Sale Packing List'
)
sequence
.
edit
(
packing_list_line_a_to_b
=
packing_list_line_a_to_b
)
def
stepCreateP
urchasePackingListForCFromA
(
self
,
sequence
=
None
,
def
stepCreateP
PLForCWarehouseXFromAWarehouseXWithQuantity10
(
self
,
sequence
=
None
,
sequence_list
=
None
,
**
kw
):
sequence_list
=
None
,
**
kw
):
#C
section
=
sequence
.
get
(
'one_more_section'
)
node
=
sequence
.
get
(
'node'
)
resource
=
sequence
.
get
(
'resource'
)
resource
=
sequence
.
get
(
'resource'
)
#A
C
=
sequence
.
get
(
'one_more_section'
)
mirror_section
=
sequence
.
get
(
'section'
)
X
=
sequence
.
get
(
'node'
)
mirror_node
=
sequence
.
get
(
'node'
)
A
=
sequence
.
get
(
'section'
)
packing_list_line_a_to_c
=
self
.
stepCreatePackingList
(
sequence
=
sequence
,
X
=
sequence
.
get
(
'node'
)
at_date
=
DateTime
(
'2013/02/11 04:00:00 GMT+9'
)
self
.
stepCreatePackingList
(
sequence
=
sequence
,
sequence_list
=
sequence_list
,
sequence_list
=
sequence_list
,
section
=
section
,
section
=
C
,
node
=
node
,
node
=
X
,
mirror_section
=
mirror_section
,
mirror_section
=
A
,
mirror_node
=
mirror_node
,
mirror_node
=
X
,
resource
=
resource
,
resource
=
resource
,
quantity
=
10
,
quantity
=
10
,
at_date
=
at_date
,
packing_list
=
'Purchase Packing List'
)
packing_list
=
'Purchase Packing List'
)
sequence
.
edit
(
packing_list_line_a_to_c
=
packing_list_line_a_to_c
)
def
stepCancelSPLFromAWarehouseXToBWarehouseYWithQuantity30
(
self
,
sequence
=
None
,
sequence_list
=
None
,
**
kw
):
A
=
sequence
.
get
(
'section'
)
X
=
sequence
.
get
(
'node'
)
B
=
sequence
.
get
(
'other_section'
)
Y
=
sequence
.
get
(
'other_node'
)
resource
=
sequence
.
get
(
'resource'
)
at_date
=
DateTime
(
'2013/02/14 06:00:00 GMT+9'
)
def
stepCreatePurchasePackingListForCFromB
(
self
,
sequence
=
None
,
self
.
stepCreatePackingList
(
sequence
=
sequence
,
sequence_list
=
sequence_list
,
section
=
A
,
node
=
X
,
mirror_section
=
B
,
mirror_node
=
Y
,
resource
=
resource
,
quantity
=
30
,
at_date
=
at_date
,
packing_list
=
'Sale Packing List'
)
def
stepCreateProductionPFromAFactoryZToAWarehouseXWithQuantity10
(
self
,
sequence
=
None
,
sequence_list
=
None
,
**
kw
):
sequence_list
=
None
,
**
kw
):
#C
A
=
sequence
.
get
(
'section'
)
section
=
sequence
.
get
(
'one_more_section
'
)
Z
=
sequence
.
get
(
'factory
'
)
node
=
sequence
.
get
(
'node'
)
X
=
sequence
.
get
(
'node'
)
resource
=
sequence
.
get
(
'resource'
)
resource
=
sequence
.
get
(
'resource'
)
#B
at_date
=
DateTime
(
'2013/02/14 08:00:00 GMT+9'
)
mirror_section
=
sequence
.
get
(
'other_section'
)
mirror_node
=
sequence
.
get
(
'other_node'
)
self
.
stepCreatePackingList
(
sequence
=
sequence
,
packing_list_line_b_to_c
=
self
.
stepCreatePackingList
(
sequence
=
sequence
,
sequence_list
=
sequence_list
,
sequence_list
=
sequence_list
,
section
=
section
,
section
=
A
,
node
=
node
,
node
=
X
,
mirror_section
=
mirror_section
,
mirror_section
=
A
,
mirror_node
=
mirror_node
,
mirror_node
=
Z
,
resource
=
resource
,
resource
=
resource
,
quantity
=
5
,
quantity
=
10
,
packing_list
=
'Purchase Packing List'
)
at_date
=
at_date
,
sequence
.
edit
(
packing_list_line_b_to_c
=
packing_list_line_b_to_c
)
packing_list
=
'Production Packing List'
)
def
stepCreateSalePackingListFromCToA
(
self
,
sequence
=
None
,
def
stepCreateSPLFromAWarehouseXToBWarehouseYWithQuantity24
(
self
,
sequence
=
None
,
sequence_list
=
None
,
**
kw
):
sequence_list
=
None
,
**
kw
):
#A
A
=
sequence
.
get
(
'section'
)
section
=
sequence
.
get
(
'section'
)
X
=
sequence
.
get
(
'node'
)
node
=
sequence
.
get
(
'node'
)
B
=
sequence
.
get
(
'other_section'
)
Y
=
sequence
.
get
(
'other_node'
)
resource
=
sequence
.
get
(
'resource'
)
resource
=
sequence
.
get
(
'resource'
)
#C
at_date
=
DateTime
(
'2013/02/16 00:00:00 GMT+9'
)
mirror_section
=
sequence
.
get
(
'one_more_section'
)
mirror_node
=
sequence
.
get
(
'node'
)
self
.
stepCreatePackingList
(
sequence
=
sequence
,
packing_list_line_c_to_a
=
self
.
stepCreatePackingList
(
sequence
=
sequence
,
sequence_list
=
sequence_list
,
sequence_list
=
sequence_list
,
section
=
section
,
section
=
B
,
node
=
node
,
node
=
Y
,
mirror_section
=
mirror_section
,
mirror_section
=
A
,
mirror_node
=
mirror_node
,
mirror_node
=
X
,
resource
=
resource
,
resource
=
resource
,
quantity
=
2
,
quantity
=
24
,
at_date
=
at_date
,
packing_list
=
'Sale Packing List'
)
packing_list
=
'Sale Packing List'
)
sequence
.
edit
(
packing_list_line_c_to_a
=
packing_list_line_c_to_a
)
def
stepCreatePPLForCWarehouseXFromBWarehouseYWithQuantity5
(
self
,
sequence
=
None
,
sequence_list
=
None
,
**
kw
):
C
=
sequence
.
get
(
'one_more_section'
)
X
=
sequence
.
get
(
'node'
)
B
=
sequence
.
get
(
'other_section'
)
Y
=
sequence
.
get
(
'other_node'
)
resource
=
sequence
.
get
(
'resource'
)
at_date
=
DateTime
(
'2013/02/24 00:00:00 GMT+9'
)
self
.
stepCreatePackingList
(
sequence
=
sequence
,
sequence_list
=
sequence_list
,
section
=
C
,
node
=
X
,
mirror_section
=
B
,
mirror_node
=
Y
,
resource
=
resource
,
quantity
=
5
,
at_date
=
at_date
,
packing_list
=
'Purchase Packing List'
)
def
stepCreateIPLFromAWarehouseXToAWarehouseYWithQuantity33
(
self
,
sequence
=
None
,
sequence_list
=
None
,
**
kw
):
A
=
sequence
.
get
(
'section'
)
X
=
sequence
.
get
(
'node'
)
Y
=
sequence
.
get
(
'other_node'
)
resource
=
sequence
.
get
(
'resource'
)
at_date
=
DateTime
(
'2013/02/25 01:00:00 GMT+9'
)
self
.
stepCreatePackingList
(
sequence
=
sequence
,
sequence_list
=
sequence_list
,
section
=
A
,
node
=
Y
,
mirror_section
=
A
,
mirror_node
=
X
,
resource
=
resource
,
at_date
=
at_date
,
quantity
=
33
,
packing_list
=
'Internal Packing List'
)
def
stepCancelPPLForCWarehouseXFromBWarehouseYWithQuantity5
(
self
,
sequence
=
None
,
sequence_list
=
None
,
**
kw
):
C
=
sequence
.
get
(
'one_more_section'
)
X
=
sequence
.
get
(
'node'
)
B
=
sequence
.
get
(
'other_section'
)
Y
=
sequence
.
get
(
'other_node'
)
resource
=
sequence
.
get
(
'resource'
)
at_date
=
DateTime
(
'2013/02/25 02:00:00 GMT+9'
)
self
.
stepCreatePackingList
(
sequence
=
sequence
,
sequence_list
=
sequence_list
,
section
=
B
,
node
=
Y
,
mirror_section
=
C
,
mirror_node
=
X
,
resource
=
resource
,
quantity
=
5
,
at_date
=
at_date
,
packing_list
=
'Purchase Packing List'
)
def
stepCreatePPLForCWarehouseXFromBWarehouseYWithQuantity10
(
self
,
sequence
=
None
,
sequence_list
=
None
,
**
kw
):
C
=
sequence
.
get
(
'one_more_section'
)
X
=
sequence
.
get
(
'node'
)
B
=
sequence
.
get
(
'other_section'
)
Y
=
sequence
.
get
(
'other_node'
)
resource
=
sequence
.
get
(
'resource'
)
at_date
=
DateTime
(
'2013/02/26 00:00:00 GMT+9'
)
self
.
stepCreatePackingList
(
sequence
=
sequence
,
sequence_list
=
sequence_list
,
section
=
C
,
node
=
X
,
mirror_section
=
B
,
mirror_node
=
Y
,
resource
=
resource
,
quantity
=
10
,
at_date
=
at_date
,
packing_list
=
'Purchase Packing List'
)
def
stepCreateOneMoreSection
(
self
,
sequence
=
None
,
sequence_list
=
None
,
**
kw
):
self
.
stepCreateOrganisation
(
sequence
=
sequence
,
sequence_list
=
sequence_list
,
**
kw
)
one_more_section
=
sequence
.
get
(
'organisation'
)
sequence
.
edit
(
one_more_section
=
one_more_section
)
def
stepCreateFactory
(
self
,
sequence
=
None
,
sequence_list
=
None
,
**
kw
):
self
.
stepCreateOrganisation
(
sequence
=
sequence
,
sequence_list
=
sequence_list
,
**
kw
)
factory
=
sequence
.
get
(
'organisation'
)
sequence
.
edit
(
factory
=
factory
)
def
stepDeliverProductionPackingList
(
self
,
sequence
=
None
,
sequence_list
=
None
,
**
kw
):
# Switch to "started" state
packing_list
=
sequence
.
get
(
'packing_list'
)
workflow_tool
=
self
.
getPortal
().
portal_workflow
workflow_tool
.
doActionFor
(
packing_list
,
"confirm_action"
,
"production_packing_list_workflow"
)
self
.
commit
()
# Apply tic so that the packing list is not in building state
self
.
tic
()
# acceptable here because this is not the job
# of the test to check if can do all transition
# without processing messages
workflow_tool
.
doActionFor
(
packing_list
,
"set_ready_action"
,
"production_packing_list_workflow"
)
self
.
tic
()
workflow_tool
.
doActionFor
(
packing_list
,
"start_action"
,
"production_packing_list_workflow"
)
workflow_tool
.
doActionFor
(
packing_list
,
"stop_action"
,
"production_packing_list_workflow"
)
workflow_tool
.
doActionFor
(
packing_list
,
"deliver_action"
,
"production_packing_list_workflow"
)
def
step
testCircularMovementQuantit
y
(
self
,
sequence
=
None
,
def
step
TestMultiCancelInventor
y
(
self
,
sequence
=
None
,
sequence_list
=
None
,
**
kw
):
sequence_list
=
None
,
**
kw
):
resource_value
=
sequence
.
get
(
'resource'
)
resource_value
=
sequence
.
get
(
'resource'
)
node_value
=
sequence
.
get
(
'node
'
)
A
=
sequence
.
get
(
'section
'
)
other_node_value
=
sequence
.
get
(
'other_node
'
)
B
=
sequence
.
get
(
'other_section
'
)
section_value
=
sequence
.
get
(
'
section'
)
C
=
sequence
.
get
(
'one_more_
section'
)
other_section_value
=
sequence
.
get
(
'other_section
'
)
X
=
sequence
.
get
(
'node
'
)
one_more_section_value
=
sequence
.
get
(
'one_more_section
'
)
Y
=
sequence
.
get
(
'other_node
'
)
#C
self
.
_testGetInventory
(
self
.
_testGetInventory
(
expected
=
13
,
expected
=
33
,
section_uid
=
one_more_section_value
.
getUid
(),
section_uid
=
A
.
getUid
(),
node_uid
=
node_value
.
getUid
(),
node_uid
=
Y
.
getUid
(),
resource_uid
=
resource_value
.
getUid
()
resource_uid
=
resource_value
.
getUid
())
)
#B
self
.
_testGetInventory
(
self
.
_testGetInventory
(
expected
=
45
,
expected
=
43
,
section_uid
=
other_section_value
.
getUid
(),
section_uid
=
A
.
getUid
(),
node_uid
=
other_node_value
.
getUid
(),
node_uid
=
X
.
getUid
(),
resource_uid
=
resource_value
.
getUid
()
resource_uid
=
resource_value
.
getUid
())
)
#A
self
.
_testGetInventory
(
self
.
_testGetInventory
(
expected
=
7
,
expected
=
14
,
section_uid
=
section_value
.
getUid
(),
section_uid
=
B
.
getUid
(),
node_uid
=
node_value
.
getUid
(),
node_uid
=
Y
.
getUid
(),
resource_uid
=
resource_value
.
getUid
()
resource_uid
=
resource_value
.
getUid
())
)
self
.
_testGetInventory
(
def
steptestCircularMovementPrice
(
self
,
sequence
=
None
,
expected
=
20
,
sequence_list
=
None
,
**
kw
):
section_uid
=
C
.
getUid
(),
resource_value
=
sequence
.
get
(
'resource'
)
node_uid
=
X
.
getUid
(),
node_value
=
sequence
.
get
(
'node'
)
resource_uid
=
resource_value
.
getUid
())
other_node_value
=
sequence
.
get
(
'other_node'
)
section_value
=
sequence
.
get
(
'section'
)
other_section_value
=
sequence
.
get
(
'other_section'
)
one_more_section_value
=
sequence
.
get
(
'one_more_section'
)
#C
self
.
_testGetInventoryAssetPrice
(
expected
=
160
,
section_uid
=
one_more_section_value
.
getUid
(),
node_uid
=
node_value
.
getUid
(),
resource_uid
=
resource_value
.
getUid
(),
valuation_method
=
'WeightedAverage'
)
#B
self
.
_testGetInventoryAssetPrice
(
expected
=
129
,
section_uid
=
other_section_value
.
getUid
(),
node_uid
=
other_node_value
.
getUid
(),
resource_uid
=
resource_value
.
getUid
(),
valuation_method
=
'WeightedAverage'
)
#A
self
.
_testGetInventoryAssetPrice
(
expected
=
178
,
section_uid
=
section_value
.
getUid
(),
node_uid
=
node_value
.
getUid
(),
resource_uid
=
resource_value
.
getUid
(),
valuation_method
=
'WeightedAverage'
)
def
test_21_CircularMovements
(
self
,
quite
=
0
,
run
=
run_all_test
):
at_date
=
DateTime
(
'2013/02/15 00:00:00 GMT+9'
)
self
.
_testGetInventory
(
expected
=
0
,
section_uid
=
A
.
getUid
(),
node_uid
=
Y
.
getUid
(),
at_date
=
at_date
,
resource_uid
=
resource_value
.
getUid
())
self
.
_testGetInventory
(
expected
=
100
,
section_uid
=
A
.
getUid
(),
node_uid
=
X
.
getUid
(),
at_date
=
at_date
,
resource_uid
=
resource_value
.
getUid
())
self
.
_testGetInventory
(
expected
=
0
,
section_uid
=
B
.
getUid
(),
node_uid
=
Y
.
getUid
(),
at_date
=
at_date
,
resource_uid
=
resource_value
.
getUid
())
self
.
_testGetInventory
(
expected
=
10
,
section_uid
=
C
.
getUid
(),
node_uid
=
X
.
getUid
(),
at_date
=
at_date
,
resource_uid
=
resource_value
.
getUid
())
at_date
=
DateTime
(
'2013/02/25 00:00:00 GMT+9'
)
self
.
_testGetInventory
(
expected
=
0
,
section_uid
=
A
.
getUid
(),
node_uid
=
Y
.
getUid
(),
at_date
=
at_date
,
resource_uid
=
resource_value
.
getUid
())
self
.
_testGetInventory
(
expected
=
76
,
section_uid
=
A
.
getUid
(),
node_uid
=
X
.
getUid
(),
at_date
=
at_date
,
resource_uid
=
resource_value
.
getUid
())
self
.
_testGetInventory
(
expected
=
19
,
section_uid
=
B
.
getUid
(),
node_uid
=
Y
.
getUid
(),
at_date
=
at_date
,
resource_uid
=
resource_value
.
getUid
())
self
.
_testGetInventory
(
expected
=
15
,
section_uid
=
C
.
getUid
(),
node_uid
=
X
.
getUid
(),
at_date
=
at_date
,
resource_uid
=
resource_value
.
getUid
())
def
test_20_InventoryWhenCancelPackingList
(
self
,
quite
=
0
,
run
=
run_all_test
):
"""
"""
Owner A, warehouse X, product G, quantity 10, total price is 1000
initial 2013/02/10 00:00:00 GMT+9:
Owner B, warehouse Y, product G, quantity 20, total price is 1100
A warehouse X, has product: Notvariated 100
Owner C, warehouse X, product G, quantity 0 , total price is 0
2013/02/11 00:00:00 GMT+9
IPL 1: A warehouse X ----> A warehouse Y, quantity: 3
2013/02/11 02:00:00 GMT+9
cancel IPL1
Then, product G was moved like below:
2013/02/13 04:00:00 GMT+9
IPL 2: A warehouse X ----> A warehouse Y, quantity: 30
2013/02/14 04:00:00 GMT+9
SPL 1: A warehouse X ----> B warehouse Y, quantity: 30
2013/02/14 05:00:00 GMT+9
cancel IPL2
2013/02/11 04:00:00 GMT+9
PPL 1: A warehouse X ----> C warehouse X, quantity: 10
2013/02/14 06:00:00 GMT+9
cancel SPL1
2013/02/14 08:00:00 GMT+9
Production PL: A factory Z ---> A warehouse X, quantity: 10
2013/02/16 00:00:00 GMT+9
SPL 2: A warehouse X ----> B warehouse Y, quantity: 24
2013/02/24 00:00:00 GMT+9
PPL 2: B warehouse Y ----> C warehouse X, quantity: 5
2013/02/25 01:00:00 GMT+9
IPL 3: A warehouse X ----> A warehouse Y, quantity: 33
Owner A purchased 15 of product G for the price of 3000
2013/02/25 02:00:00 GMT+9
Owner A purchased 20 of product G for the price of 4000
cancel PPL 2
Owner B purchased 30 of product G from Owner A(price is determined at the end of Nov).
2013/02/26 00:00:00 GMT+9
Owner C purchased 10 of product G from Owner A(price is determined at the end of Nov).
PPL 3: B warehouse Y ----> C warehouse X, quantity: 10
Owner C get 5 of product G from Owner B(price is determined at the end of Nov).
Owner A get 2 of product G from Owner C(price is determined at the end of Nov).
As we see in this example, product G was moved between A and B, B and
C, C and A, it is circulating. Then, at the end of Mouth, Price of
product G of Owner A depends on price of product G of owner B, this
kind of thing happens. (And if it is a real circulation, price can't be
decided, it must not happen, but theoretically it can happen.
"""
"""
if
not
run
:
return
if
not
run
:
return
sequence_list
=
SequenceList
()
sequence_list
=
SequenceList
()
sequence_string
=
'CreateOrganisationsForModule
\
sequence_string
=
'CreateOrganisationsForModule
\
CreateOneMoreSection
\
CreateOneMoreSection
\
CreateFactory
\
CreateNotVariatedResource
\
CreateNotVariatedResource
\
Tic
\
Tic
\
CreateSalePackingListToA
\
InitialAWarehouseX
\
Tic
\
DeliverPackingList
\
Tic
\
CreateIPLFromAWarehouseXToAWarehouseYWithQuantity3
\
Tic
\
Tic
\
DeliverPackingList
\
DeliverPackingList
\
Tic
\
Tic
\
C
reatePurchasePackingListForB
\
C
ancelIPLFromAWarehouseXToAWarehouseYWithQuantity3
\
Tic
\
Tic
\
DeliverPackingList
\
DeliverPackingList
\
Tic
\
Tic
\
CreatePurchasePackingListForASecond
\
CreateIPLFromAWarehouseXToAWarehouseYWithQuantity30
\
Tic
\
DeliverPackingList
\
Tic
\
CreateSPLFromAWarehouseXToBWarehouseYWithQuantity30
\
Tic
\
DeliverPackingList
\
DeliverPackingList
\
Tic
\
Tic
\
CreatePurchasePackingListForAThird
\
CancelIPLFromAWarehouseXToAWarehouseYWithQuantity30
\
Tic
\
DeliverPackingList
\
Tic
\
CreatePPLForCWarehouseXFromAWarehouseXWithQuantity10
\
Tic
\
DeliverPackingList
\
Tic
\
CancelSPLFromAWarehouseXToBWarehouseYWithQuantity30
\
Tic
\
DeliverPackingList
\
DeliverPackingList
\
Tic
\
Tic
\
CreateSalePackingListFromAToB
\
CreateProductionPFromAFactoryZToAWarehouseXWithQuantity10
\
Tic
\
DeliverProductionPackingList
\
Tic
\
CreateSPLFromAWarehouseXToBWarehouseYWithQuantity24
\
Tic
\
DeliverPackingList
\
DeliverPackingList
\
Tic
\
Tic
\
CreatePurchasePackingListForCFromA
\
CreatePPLForCWarehouseXFromBWarehouseYWithQuantity5
\
Tic
\
DeliverPackingList
\
DeliverPackingList
\
Tic
\
Tic
\
CreatePurchasePackingListForCFromB
\
CreateIPLFromAWarehouseXToAWarehouseYWithQuantity33
\
Tic
\
DeliverPackingList
\
DeliverPackingList
\
Tic
\
Tic
\
CreateSalePackingListFromCToA
\
CancelPPLForCWarehouseXFromBWarehouseYWithQuantity5
\
Tic
\
DeliverPackingList
\
DeliverPackingList
\
Tic
\
Tic
\
steptestCircularMovementQuantity
\
CreatePPLForCWarehouseXFromBWarehouseYWithQuantity10
\
Tic
\
Tic
\
steptestCircularMovementPrice
\
DeliverPackingList
\
Tic
\
TestMultiCancelInventory
\
'
'
sequence_list
.
addSequenceString
(
sequence_string
)
sequence_list
.
addSequenceString
(
sequence_string
)
sequence_list
.
play
(
self
)
sequence_list
.
play
(
self
)
def
test_suite
():
def
test_suite
():
suite
=
unittest
.
TestSuite
()
suite
=
unittest
.
TestSuite
()
...
...
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