diff --git a/bijoe/schemas.py b/bijoe/schemas.py index 2759254..109e3ba 100644 --- a/bijoe/schemas.py +++ b/bijoe/schemas.py @@ -288,8 +288,11 @@ class Dimension(Base): def build_filter(self, filter_values): value = self.filter_value or self.value - if self.type == 'date': - assert isinstance(filter_values, dict) and set(filter_values.keys()) == {'start', 'end'} + if ( + self.type == 'date' + and isinstance(filter_values, dict) + and set(filter_values.keys()) == {'start', 'end'} + ): filters = [] values = [] @@ -326,6 +329,8 @@ class Dimension(Base): filter_value = int(filter_value) elif self.type == 'bool': filter_value = bool(filter_value) + elif self.type == 'date': + filter_value = filter_value.isoformat() else: raise NotImplementedError except (ValueError, TypeError): diff --git a/tests/test_schema1.py b/tests/test_schema1.py index 0596056..4908293 100644 --- a/tests/test_schema1.py +++ b/tests/test_schema1.py @@ -498,3 +498,18 @@ def test_date_dimension(schema1, app, admin): ['09/01/2017', '1'], ['10/01/2017', '1'], ] + + +def test_date_dimension_loop(schema1, app, admin): + login(app, admin) + response = app.get('/') + response = response.click('schema1') + response = response.click('Facts 1') + form = response.form + form.set('representation', 'table') + form.set('measure', 'simple_count') + form.set('loop', 'date') + form.set('filter__date_0', '2017-01-01') + form.set('filter__date_1', '2017-02-01') + response = form.submit('visualize') + assert get_table(response) == [['number of rows', '1']] * 10