Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
E
erp5_rtl_support
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
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Romain Courteaud
erp5_rtl_support
Commits
76919bdc
Commit
76919bdc
authored
Mar 27, 2013
by
Tatuya Kamada
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Unit Test: Add a test to confirm Create Full Inventory then add Old Movement case
parent
c955609f
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
131 additions
and
4 deletions
+131
-4
product/ERP5/tests/testInventory.py
product/ERP5/tests/testInventory.py
+131
-4
No files found.
product/ERP5/tests/testInventory.py
View file @
76919bdc
...
@@ -351,14 +351,18 @@ class TestInventory(TestOrderMixin, ERP5TypeTestCase):
...
@@ -351,14 +351,18 @@ class TestInventory(TestOrderMixin, ERP5TypeTestCase):
portal_type
=
self
.
packing_list_portal_type
)
portal_type
=
self
.
packing_list_portal_type
)
packing_list
=
packing_list_module
.
newContent
(
packing_list
=
packing_list_module
.
newContent
(
portal_type
=
self
.
packing_list_portal_type
)
portal_type
=
self
.
packing_list_portal_type
)
if
kw
.
get
(
'start_date'
,
None
)
is
not
None
:
start_date
=
stop_date
=
kw
[
'start_date'
]
else
:
start_date
=
stop_date
=
DateTime
()
-
2
packing_list
.
edit
(
packing_list
.
edit
(
specialise
=
self
.
business_process
,
specialise
=
self
.
business_process
,
source_section_value
=
mirror_section
,
source_section_value
=
mirror_section
,
source_value
=
mirror_node
,
source_value
=
mirror_node
,
destination_section_value
=
section
,
destination_section_value
=
section
,
destination_value
=
node
,
destination_value
=
node
,
start_date
=
DateTime
()
-
2
,
start_date
=
start_date
,
stop_date
=
DateTime
()
-
2
,
stop_date
=
stop_date
,
price_currency
=
self
.
price_currency
price_currency
=
self
.
price_currency
)
)
self
.
assertNotEquals
(
packing_list
.
getSourceSectionValue
(),
None
)
self
.
assertNotEquals
(
packing_list
.
getSourceSectionValue
(),
None
)
...
@@ -2185,14 +2189,18 @@ class TestInventory(TestOrderMixin, ERP5TypeTestCase):
...
@@ -2185,14 +2189,18 @@ class TestInventory(TestOrderMixin, ERP5TypeTestCase):
def
stepCreateFullInventoryAtTheDate
(
self
,
sequence
=
None
,
def
stepCreateFullInventoryAtTheDate
(
self
,
sequence
=
None
,
sequence_list
=
None
,
**
kw
):
sequence_list
=
None
,
**
kw
):
""" Create Full Inventory at the date
: '2013/03/12 GMT+9
' """
""" Create Full Inventory at the date' """
inventory_list
=
sequence
.
get
(
'inventory_list'
,[])
inventory_list
=
sequence
.
get
(
'inventory_list'
,[])
self
.
assertEquals
(
len
(
inventory_list
),
0
)
self
.
assertEquals
(
len
(
inventory_list
),
0
)
if
kw
.
get
(
'start_date'
,
None
)
is
not
None
:
start_date
=
kw
[
'start_date'
]
else
:
start_date
=
'2013/03/12 00:00:00 GMT+9'
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'
),
destination_value
=
sequence
.
get
(
'node'
),
destination_value
=
sequence
.
get
(
'node'
),
start_date
=
'2013/03/12 00:00:00 GMT+9'
)
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
=
sequence
.
get
(
"resource"
),
...
@@ -2202,6 +2210,14 @@ class TestInventory(TestOrderMixin, ERP5TypeTestCase):
...
@@ -2202,6 +2210,14 @@ class TestInventory(TestOrderMixin, ERP5TypeTestCase):
sequence
.
edit
(
inventory_list
=
inventory_list
)
sequence
.
edit
(
inventory_list
=
inventory_list
)
def
stepCreateFullInventoryAtTheDate1
(
self
,
sequence
=
None
,
sequence_list
=
None
,
**
kw
):
if
getattr
(
self
,
'inventory_start_date_1'
,
None
)
is
None
:
raise
UnboundLocalError
(
'Please assign self.inventory_start_date_1 '
'in your test method'
)
self
.
stepCreateFullInventoryAtTheDate
(
sequence
,
sequence_list
,
start_date
=
self
.
inventory_start_date_1
)
def
stepCheckMultipleSectionAndFullInventory
(
self
,
sequence
=
None
,
def
stepCheckMultipleSectionAndFullInventory
(
self
,
sequence
=
None
,
sequence_list
=
None
,
**
kw
):
sequence_list
=
None
,
**
kw
):
""" Check that getInvetory() is surely working in
""" Check that getInvetory() is surely working in
...
@@ -2265,6 +2281,71 @@ class TestInventory(TestOrderMixin, ERP5TypeTestCase):
...
@@ -2265,6 +2281,71 @@ class TestInventory(TestOrderMixin, ERP5TypeTestCase):
workflow_action
()
workflow_action
()
self
.
tic
()
self
.
tic
()
def
stepCreatePackingListAtTheDate1
(
self
,
sequence
=
None
,
sequence_list
=
None
,
**
kw
):
""" Create Packing List with self.start_date_1"""
if
getattr
(
self
,
'start_date_1'
,
None
)
is
None
:
raise
UnboundLocalError
(
'Please Assign self.start_date_1 '
'in your test method'
)
start_date
=
self
.
start_date_1
self
.
stepCreatePackingListForModule
(
sequence
=
sequence
,
sequence_list
=
sequence_list
,
start_date
=
start_date
)
def
stepCreatePackingListAtTheDate2
(
self
,
sequence
=
None
,
sequence_list
=
None
,
**
kw
):
""" Create Packing List with self.start_date_2"""
if
getattr
(
self
,
'start_date_2'
,
None
)
is
None
:
raise
UnboundLocalError
(
'Please Assign self.start_date_2 '
'in your test method'
)
start_date
=
self
.
start_date_2
self
.
stepCreatePackingListForModule
(
sequence
=
sequence
,
sequence_list
=
sequence_list
,
start_date
=
start_date
)
def
_testGetMovementHistoryList
(
self
,
expected_history
=
None
,
**
kw
):
""" Helper method to check getMovementHistoryList """
simulation
=
self
.
getPortal
().
portal_simulation
LOG
(
'Testing movement history with args :'
,
0
,
kw
)
result
=
simulation
.
getMovementHistoryList
(
**
kw
)
self
.
assertTrue
(
len
(
result
)
>
0
)
# Note: Now only checking total_quantity but can be checked more
actual_history
=
[{
'total_quantity'
:
x
.
total_quantity
}
for
x
in
result
]
try
:
self
.
assertEquals
(
len
(
expected_history
),
len
(
actual_history
))
for
expected
,
actual
in
zip
(
expected_history
,
actual_history
):
shared_keys
=
set
(
expected
.
keys
())
&
set
(
actual
.
keys
())
self
.
assertEquals
(
len
(
shared_keys
),
len
(
expected
.
keys
()))
shared_item
=
set
(
expected
.
items
())
&
set
(
actual
.
items
())
self
.
assertEquals
(
len
(
shared_item
),
len
(
expected
.
keys
()))
except
AssertionError
:
msg
=
'History differs between expected:
\
n
%s
\
n
and real:
\
n
%s'
\
%
(
repr
(
expected_history
),
repr
(
actual_history
))
LOG
(
'TestInventory._testGetMovementHistoryList'
,
0
,
msg
)
LOG
(
'SQL Query was : '
,
0
,
str
(
simulation
.
getMovementHistoryList
(
src__
=
1
,
**
kw
)))
raise
AssertionError
(
msg
)
def
stepCheckFullInventoryAddOldMovement
(
self
,
sequence
=
None
,
sequence_list
=
None
,
**
kw
):
""" Check Create Full Inventory Then Add Old Movement use case """
section
=
sequence
.
get
(
'section'
)
node
=
sequence
.
get
(
'node'
)
self
.
_testGetInventory
(
expected
=
100
,
section_uid
=
section
.
getUid
(),
node_uid
=
node
.
getUid
())
self
.
_testGetMovementHistoryList
(
expected_history
=
[{
'total_quantity'
:
-
100
},
{
'total_quantity'
:
100
},
{
'total_quantity'
:
100
},],
section_uid
=
section
.
getUid
(),
node_uid
=
node
.
getUid
())
def
test_01_getInventory
(
self
,
quiet
=
0
,
run
=
run_all_test
):
def
test_01_getInventory
(
self
,
quiet
=
0
,
run
=
run_all_test
):
"""
"""
...
@@ -2597,6 +2678,52 @@ class TestInventory(TestOrderMixin, ERP5TypeTestCase):
...
@@ -2597,6 +2678,52 @@ class TestInventory(TestOrderMixin, ERP5TypeTestCase):
sequence_list
.
addSequenceString
(
sequence_string
)
sequence_list
.
addSequenceString
(
sequence_string
)
sequence_list
.
play
(
self
)
sequence_list
.
play
(
self
)
# Note: This inventory reindex function is not implemented yet
@
expectedFailure
def
test_11_FullInventoryAddOldMovement
(
self
,
quiet
=
0
,
run
=
run_all_test
):
"""
Make sure the following case:
1) add movement 2013/02/10, quantity=100
2) full inventory: 2013/03/15, quantity=100
[test]
getInventory() should return 100
getMovementHistory() should return 100 ([100])
3) add movement: 2013/02/01, quantity=100
[test]
getInventory() should return 100
getMovementHistory() should return 100 ([-100, 100, 100])
"""
if
not
run
:
return
self
.
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_2
=
'2013/02/01 00:00:00 GMT+9'
sequence_list
=
SequenceList
()
sequence_string
=
'CreateOrganisationsForModule
\
CreateNotVariatedResource
\
Tic
\
CreatePackingListAtTheDate1
\
CreatePackingListLine
\
Tic
\
DeliverPackingList
\
Tic
\
CreateFullInventoryAtTheDate1
\
Tic
\
CreatePackingListAtTheDate2
\
CreatePackingListLine
\
Tic
\
DeliverPackingList
\
Tic
\
CheckFullInventoryAddOldMovement
\
'
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