[FIX] orm: Adapt test and read_group_fill_temporal

In the commit 4a40db2. the implementation of read_group_fill_temporal was
simplified during final review and tests needed to be adapted.

Also fix the implementation issues as detected by the tests.
This commit is contained in:
Francois Volral
2018-08-10 18:15:27 +02:00
parent 4b3766e8eb
commit 6caf5ed7d2
2 changed files with 7 additions and 11 deletions
-8
View File
@@ -162,14 +162,6 @@ class TestDateRangeFunction(unittest.TestCase):
self.assertEqual(dates, expected)
def test_date_range_with_identical_boundaries(self):
""" date_range with indentical boundaries. """
start = datetime.datetime(1985, 1, 1)
end = datetime.datetime(1985, 1, 1)
with self.assertRaises(ValueError):
dates = [date for date in date_utils.date_range(start, end)]
class TestFormatLangDate(TransactionCase):
def test_00_accepted_types(self):
+7 -3
View File
@@ -1811,7 +1811,7 @@ class BaseModel(MetaModel('DummyModel', (object,), {'_register': False})):
# assumption: existing data is sorted by field 'groupby_name'
first, last = existing[0], existing[-1]
expected = list(date_utils.date_range(first, last, interval))
expected = collections.deque(date_utils.date_range(first, last, interval))
if len(existing) < len(expected):
empty_data = dict.fromkeys(aggregated_fields, False)
@@ -1827,8 +1827,12 @@ class BaseModel(MetaModel('DummyModel', (object,), {'_register': False})):
# is sorted like data, so what we do is empty data progressivly by
# popping its elements from first to last. To do this properly, we
# need to compare dates together.
for dt in expected:
if not data[0][groupby_name] or data[0][groupby_name] == dt:
while expected or data:
if not data[0][groupby_name]:
new_data.append(data.popleft())
continue
dt = expected.popleft()
if data[0][groupby_name] == dt:
new_data.append(data.popleft())
else:
new_data.append(dict(empty_data, **{groupby_name: dt}))