Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions predicthq/endpoints/v1/events/schemas.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ class Options:
start = ModelType(DateTimeRange)
end = ModelType(DateTimeRange)
active = ModelType(DateTimeRange)
updated = ModelType(DateTimeRange)
state = StringType(choices=('active', 'deleted'))
rank_level = ListType(IntType(min_value=1, max_value=5))
rank = ModelType(IntRange)
country = ListType(StringType)
Expand Down
16 changes: 12 additions & 4 deletions tests/endpoints/v1/events_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,36 +15,44 @@ class EventsTest(unittest.TestCase):
def test_search_params_underscores(self, client):
client.events.search(id="id", q="query", rank_level=[4,5], rank__gt=85, country=["NZ", "AU"],
within__radius="2km", within__longitude=-71.0432, within__latitude=42.346,
label=["label1", "label2"], category="category",
label=["label1", "label2"], category="category", state='deleted',
place__scope=["place1", "place2"], place__exact=["place3"],
start__gte="2016-03-01", start__lt=datetime(2016, 4, 1), start__tz="Pacific/Auckland",
end__gte="2016-05-01", end__lt=datetime(2016, 6, 1), end__tz="Pacific/Auckland",
active__gte="2016-03-01", active__lt=datetime(2016, 4, 1), active__tz="Pacific/Auckland",
updated__gte="2016-03-01", updated__lt=datetime(2016, 4, 1), updated__tz="Pacific/Auckland",
signal__id="zVNLr8tHvWQw", signal__explain=datetime(2016, 4, 1))

client.request.assert_called_once_with('get', '/v1/events/', params={
'id': 'id', 'rank.gt': 85, 'rank_level': '4,5', 'category': 'category', 'country': 'NZ,AU',
'id': 'id', 'rank.gt': 85, 'rank_level': '4,5', 'category': 'category', 'state': 'deleted', 'country': 'NZ,AU',
'within': '2km@42.346,-71.0432', 'label': 'label1,label2', 'q': 'query',
'place.scope': 'place1,place2', 'place.exact': 'place3',
'start.lt': '2016-04-01T00:00:00.000000', 'start.gte': '2016-03-01T00:00:00.000000', 'start.tz': 'Pacific/Auckland',
'end.lt': '2016-06-01T00:00:00.000000', 'end.gte': '2016-05-01T00:00:00.000000', 'end.tz': 'Pacific/Auckland',
'active.lt': '2016-04-01T00:00:00.000000', 'active.gte': '2016-03-01T00:00:00.000000', 'active.tz': 'Pacific/Auckland',
'updated.lt': '2016-04-01T00:00:00.000000', 'updated.gte': '2016-03-01T00:00:00.000000', 'updated.tz': 'Pacific/Auckland',
'signal.id': 'zVNLr8tHvWQw', 'signal.explain': '2016-04-01'})

@with_mock_client()
def test_search_params_dicts(self, client):
client.events.search(id="id", q="query", rank_level=[4,5], rank={"gt": 85}, country=["NZ", "AU"],
within={"radius": "2km", "longitude": -71.0432, "latitude": 42.346},
label=["label1", "label2"], category="category",
label=["label1", "label2"], category="category", state='deleted',
place={"scope": ["place1", "place2"], "exact": "place3"},
start={"gte": "2016-03-01", "lt": datetime(2016, 4, 1), "tz": "Pacific/Auckland"},
end={"gte": "2016-05-01", "lt": datetime(2016, 6, 1), "tz": "Pacific/Auckland"},
active={"gte": "2016-03-01", "lt": datetime(2016, 4, 1), "tz": "Pacific/Auckland"},
updated={"gte": "2016-03-01", "lt": datetime(2016, 4, 1), "tz": "Pacific/Auckland"},
signal={"id": "zVNLr8tHvWQw", "explain": datetime(2016, 4, 1)})

client.request.assert_called_once_with('get', '/v1/events/', params={
'id': 'id', 'rank.gt': 85, 'rank_level': '4,5', 'category': 'category', 'country': 'NZ,AU',
'id': 'id', 'rank.gt': 85, 'rank_level': '4,5', 'category': 'category', 'state': 'deleted', 'country': 'NZ,AU',
'within': '2km@42.346,-71.0432', 'label': 'label1,label2', 'q': 'query',
'place.scope': 'place1,place2', 'place.exact': 'place3',
'start.lt': '2016-04-01T00:00:00.000000', 'start.gte': '2016-03-01T00:00:00.000000', 'start.tz': 'Pacific/Auckland',
'end.lt': '2016-06-01T00:00:00.000000', 'end.gte': '2016-05-01T00:00:00.000000', 'end.tz': 'Pacific/Auckland',
'active.lt': '2016-04-01T00:00:00.000000', 'active.gte': '2016-03-01T00:00:00.000000', 'active.tz': 'Pacific/Auckland',
'updated.lt': '2016-04-01T00:00:00.000000', 'updated.gte': '2016-03-01T00:00:00.000000', 'updated.tz': 'Pacific/Auckland',
'signal.id': 'zVNLr8tHvWQw', 'signal.explain': '2016-04-01'})

@with_mock_client()
Expand Down