def test_limit_offset_filtered_offset(client): response = client.get('/limit_offset_widgets?size=2&offset=1') assert helpers.get_data(response) == [ { 'id': '5', 'size': 2, }, ] assert helpers.get_meta(response) == { 'has_next_page': False }
def test_limit_offset_offset_truncate(client): response = client.get('/limit_offset_widgets?offset=5') assert helpers.get_data(response) == [ { 'id': '6', 'size': 3, }, ] assert helpers.get_meta(response) == { 'has_next_page': False }
def test_page_default(client): response = client.get('/page_widgets') assert helpers.get_data(response) == [ { 'id': '1', 'size': 1, }, { 'id': '2', 'size': 2, }, ] assert helpers.get_meta(response) == { 'has_next_page': True }
def test_page(client): response = client.get('/page_widgets?page=1') assert helpers.get_data(response) == [ { 'id': '3', 'size': 3, }, { 'id': '4', 'size': 1, }, ] assert helpers.get_meta(response) == { 'has_next_page': True }
def test_limit_offset_offset(client): response = client.get('/limit_offset_widgets?offset=2') assert helpers.get_data(response) == [ { 'id': '3', 'size': 3, }, { 'id': '4', 'size': 1, }, ] assert helpers.get_meta(response) == { 'has_next_page': True }
def test_id_cursor_sorted_default(client): response = client.get('/id_cursor_widgets?sort=size,-id') assert helpers.get_data(response) == [ { 'id': '4', 'size': 1, }, { 'id': '1', 'size': 1, }, ] assert helpers.get_meta(response) == { 'has_next_page': True, 'cursors': [ 'WzEsIDRd', 'WzEsIDFd', ], }
def test_id_cursor_default(client): response = client.get('/id_cursor_widgets') assert helpers.get_data(response) == [ { 'id': '1', 'size': 1, }, { 'id': '2', 'size': 2, }, ] assert helpers.get_meta(response) == { 'has_next_page': True, 'cursors': [ 'WzFd', 'WzJd', ], }
def meta(url): html_tree = helpers.open_url(url) meta = helpers.get_meta(html_tree) dict = {'meta': meta} return jsonify(dict)