Commit d810b3ef authored by Jérome Perrin's avatar Jérome Perrin

interpolation

parent 218fc444
...@@ -1260,6 +1260,19 @@ class TestInventory(InventoryAPITestCase): ...@@ -1260,6 +1260,19 @@ class TestInventory(InventoryAPITestCase):
interpolation_method='all_or_nothing') interpolation_method='all_or_nothing')
def test_interpolation_method_invalid_input(self):
# with interpolation method at least one of from_date, at_date or to_date is required.
with self.assertRaises(ValueError):
self.portal.portal_simulation.getInventoryList(
interpolation_method='linear')
with self.assertRaises(ValueError):
self.portal.portal_simulation.getInventoryList(
interpolation_method='all_or_nothing') # XXX
with self.assertRaises(ValueError):
self.portal.portal_simulation.getInventoryList(
interpolation_method='one_for_all') # XXX
class TestInventoryList(InventoryAPITestCase): class TestInventoryList(InventoryAPITestCase):
"""Tests getInventoryList methods. """Tests getInventoryList methods.
""" """
...@@ -1837,7 +1850,7 @@ class TestInventoryList(InventoryAPITestCase): ...@@ -1837,7 +1850,7 @@ class TestInventoryList(InventoryAPITestCase):
# M1 XXXXXXXXXX # M1 XXXXXXXXXX
# M2 XXXXX # M2 XXXXX
# M3 XXXXXXXXXX # M3 XXXXXXXXXX
# M4 XXXXX # M4 XXXXX
# | | | # | | |
inventory_list = self.getSimulationTool().getInventoryList( inventory_list = self.getSimulationTool().getInventoryList(
...@@ -1857,7 +1870,7 @@ class TestInventoryList(InventoryAPITestCase): ...@@ -1857,7 +1870,7 @@ class TestInventoryList(InventoryAPITestCase):
# ^^ 2 -> total for `node`: 5 # ^^ 2 -> total for `node`: 5
# M3 XXXXXXXXXX # M3 XXXXXXXXXX
# ^^^^ 4 -> total for `other_node`: 4 # ^^^^ 4 -> total for `other_node`: 4
# M4 XXXXX # M4 XXXXX
# | [ | [ | # | [ | [ |
......
...@@ -648,7 +648,8 @@ class SimulationTool(BaseTool): ...@@ -648,7 +648,8 @@ class SimulationTool(BaseTool):
if date_dict: if date_dict:
column_value_dict['date'] = date_dict column_value_dict['date'] = date_dict
if interpolation_method != 'default': if interpolation_method != 'default':
assert from_date and (to_date or at_date) if not (from_date and (to_date or at_date)):
raise ValueError("date_range is required to use interpolation_method")
# if we consider flow, we also select movement whose mirror date is # if we consider flow, we also select movement whose mirror date is
# in the from_date/to_date range and movement whose # in the from_date/to_date range and movement whose
# start_date/stop_date contains the report range. # start_date/stop_date contains the report range.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment