def test_get_event(token_first, event_in_db): """ Validate that Graphql endpoint is working fine for `event` and `events` queries. Also match data for single event. """ response = assert_valid_response('event', Event, token_first, event_in_db['id']) event = response['data']['event'] match_data(event, event_in_db, Event.get_fields(exclude=('organizer_id', 'url')))
def test_get_events_pagination(token_first, event_in_db, event_in_db_second): """ Validate that pagination is working fine. There are two events created by test user. We will get 2 events in first page and then no events in second page (request) """ assert_valid_response('event', Event, token_first, event_in_db['id']) fields = Event.get_fields() query = get_query('events', fields, args=dict(page=1, per_page=10)) response = get_graphql_data(query, token_first) assert 'errors' not in response, 'Response: %s\nQuery: %s' % (response, query) validate_graphql_response('events', response['data'], fields, is_array=True) # Since there were only two events created, now getting events for second page will return no events query = get_query('events', fields, args=dict(page=2, per_page=10)) response = get_graphql_data(query, token_first) assert 'errors' not in response, 'Response: %s\nQuery: %s' % (response, query) assert response['data']['events'] == []