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
Nikola Balog
erp5
Commits
27ef7772
Commit
27ef7772
authored
Jun 09, 2016
by
Romain Courteaud
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
testInventoryAPI: test stock cache flush with inventory in a new test method
parent
35f012a9
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
85 additions
and
2 deletions
+85
-2
product/ERP5/tests/testInventoryAPI.py
product/ERP5/tests/testInventoryAPI.py
+85
-2
No files found.
product/ERP5/tests/testInventoryAPI.py
View file @
27ef7772
...
...
@@ -3028,8 +3028,6 @@ class TestInventoryCacheTable(InventoryAPITestCase):
self
.
assertEqual
(
value
,
self
.
getInventory
(
optimisation__
=
False
,
**
inventory_kw
))
@
expectedFailure
def
test_12_CheckCacheFlush
(
self
):
"""
Test the cache is flushed when indexing a movement into stock
...
...
@@ -3146,6 +3144,91 @@ class TestInventoryCacheTable(InventoryAPITestCase):
self
.
getInventory
(
optimisation__
=
False
,
**
inventory_kw
),
)
@
expectedFailure
def
test_12_CheckCacheFlushWithInventory
(
self
):
"""
Test the cache is flushed when indexing an inventory into stock
"""
inventory_kw
=
{
'node_uid'
:
self
.
node_uid
,
'to_date'
:
self
.
NOW
,
}
# Fill cache and make stock inconsistent
value
=
self
.
getInventory
(
**
inventory_kw
)
self
.
doubleStockValue
()
# Create a movement after CACHE DATE
# Cache is cleared for all entry > movement date
# as at a cache date D, it contains results from stock
# for all line < D
INVENTORY_QUANTITY_4
=
5000
INVENTORY_DATE_4
=
self
.
CACHE_DATE
movement
=
self
.
_makeMovement
(
quantity
=
INVENTORY_QUANTITY_4
,
start_date
=
INVENTORY_DATE_4
,
simulation_state
=
'delivered'
,
)
self
.
tic
()
# Optimisation must still be used
self
.
assertEqual
(
value
+
INVENTORY_QUANTITY_4
,
self
.
getInventory
(
**
inventory_kw
),
)
# Edit start date so that cache table is cleared
movement
.
edit
(
start_date
=
self
.
LAST_CACHED_MOVEMENT_DATE
)
self
.
tic
()
self
.
assertEqual
(
value
+
INVENTORY_QUANTITY_4
+
self
.
INVENTORY_QUANTITY_1
,
self
.
getInventory
(
**
inventory_kw
),
)
self
.
doubleStockValue
()
# Cache hit again
self
.
assertEqual
(
value
+
INVENTORY_QUANTITY_4
+
self
.
INVENTORY_QUANTITY_1
,
self
.
getInventory
(
**
inventory_kw
),
)
# Move movement's start date in the future and check cache is flushed
# at former date
movement
.
edit
(
start_date
=
self
.
NOW
-
1
)
self
.
tic
()
self
.
assertEqual
(
value
+
INVENTORY_QUANTITY_4
+
3
*
self
.
INVENTORY_QUANTITY_1
,
self
.
getInventory
(
**
inventory_kw
),
)
self
.
doubleStockValue
()
# Cache hit again
self
.
assertEqual
(
value
+
INVENTORY_QUANTITY_4
+
3
*
self
.
INVENTORY_QUANTITY_1
,
self
.
getInventory
(
**
inventory_kw
),
)
# Set date back in the past, cache is clear again
movement
.
edit
(
start_date
=
self
.
LAST_CACHED_MOVEMENT_DATE
)
self
.
tic
()
self
.
assertEqual
(
value
+
INVENTORY_QUANTITY_4
+
7
*
self
.
INVENTORY_QUANTITY_1
,
self
.
getInventory
(
**
inventory_kw
),
)
self
.
doubleStockValue
()
# Cache hit again
self
.
assertEqual
(
value
+
INVENTORY_QUANTITY_4
+
7
*
self
.
INVENTORY_QUANTITY_1
,
self
.
getInventory
(
**
inventory_kw
),
)
# Delete movement, so it gets unindexed and cache entry is flushed
self
.
folder
.
manage_delObjects
(
ids
=
[
movement
.
getId
(),
])
self
.
tic
()
self
.
assertEqual
(
value
+
15
*
self
.
INVENTORY_QUANTITY_1
,
self
.
getInventory
(
**
inventory_kw
),
)
self
.
doubleStockValue
()
# Cache hit again
self
.
assertEqual
(
value
+
15
*
self
.
INVENTORY_QUANTITY_1
,
self
.
getInventory
(
**
inventory_kw
),
)
# Create an inventory
INVENTORY_QUANTITY_5
=
0
inventory
=
self
.
_makeInventory
(
...
...
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