예제 #1
0
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
    }
예제 #2
0
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
    }
예제 #3
0
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
    }
예제 #4
0
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
    }
예제 #5
0
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
    }
예제 #6
0
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',
        ],
    }
예제 #7
0
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',
        ],
    }
예제 #8
0
def meta(url):
    html_tree = helpers.open_url(url)
    meta = helpers.get_meta(html_tree)
    dict = {'meta': meta}
    return jsonify(dict)