def test_bound(self): filter = Filter() res = filter.bound(dimension='duration', lower=60, upper=180, ordering='numeric') expected = { "filter": { "type": "bound", "dimension": "duration", "lower": 60, "upper": 180, "ordering": "numeric" } } self.assertEqual(res.to_dict(), expected)
def test_and_logic(self): filter = Filter() res = filter.selector(dimension='agent_gender', value='M') & filter.selector(dimension='agent_home_state', value='1') & filter.bound(dimension='agent_year_of_birth', lower=1969, ordering='numeric') expected = { "filter": { "type": "and", "fields": [{ "type": "selector", "dimension": "agent_gender", "value": "M" }, { "type": "selector", "dimension": "agent_home_state", "value": "1" }, { "type": "bound", "dimension": "agent_year_of_birth", "lower": 1969, "ordering": "numeric" }] } } self.assertEqual(res.to_dict(), expected)