コード例 #1
0
def test_paginator__paginate_5():
    p = Paginator(max_results=5, unique_attribute=["name"])
    resp = p.paginate(results)
    resp.should.have.length_of(2)

    page, next_token = resp
    next_token.shouldnt.equal(None)
    page.should.equal(results[0:5])
コード例 #2
0
def test_paginator__paginate_with_just_max_results():
    p = Paginator(max_results=50)
    resp = p.paginate(results)
    resp.should.have.length_of(2)

    page, next_token = resp
    next_token.should.equal(None)
    page.should.equal(results)
コード例 #3
0
def test_paginator__invalid_token__but_we_just_dont_care():
    p = Paginator(
        max_results=5,
        unique_attribute=["name"],
        starting_token="unknown",
        fail_on_invalid_token=False,
    )
    res, token = p.paginate(results)

    res.should.equal([])
    token.should.equal(None)
コード例 #4
0
def test_paginator__paginate_5__use_different_range_keys():
    p = Paginator(max_results=5, unique_attribute="name")
    _, token_as_str = p.paginate(results)

    p = Paginator(max_results=5, unique_attribute=["name"])
    _, token_as_lst = p.paginate(results)

    token_as_lst.shouldnt.be(None)
    token_as_lst.should.equal(token_as_str)

    p = Paginator(max_results=5, unique_attribute=["name", "arn"])
    _, token_multiple = p.paginate(results)
    token_multiple.shouldnt.be(None)
    token_multiple.shouldnt.equal(token_as_str)
コード例 #5
0
def test_paginator__paginate_twice():
    p = Paginator(max_results=5, unique_attribute=["name"])
    resp = p.paginate(results)
    resp.should.have.length_of(2)

    page, next_token = resp

    p = Paginator(max_results=10, unique_attribute=["name"], starting_token=next_token)
    resp = p.paginate(results)

    page, next_token = resp
    next_token.should.equal(None)
    page.should.equal(results[5:])
コード例 #6
0
def test_paginator__invalid_token():
    with pytest.raises(InvalidToken):
        Paginator(max_results=5, unique_attribute=["name"], starting_token="unknown")
コード例 #7
0
def test_paginator__paginate_with_unknown_range_key__throws_error():
    p = Paginator(max_results=2, unique_attribute=["unknown"])
    with pytest.raises(KeyError):
        p.paginate(results)
コード例 #8
0
def test_paginator__paginate_without_range_key__throws_error():
    p = Paginator(max_results=2)
    with pytest.raises(KeyError):
        p.paginate(results)
コード例 #9
0
def test_paginator_without_max_results__throws_error():
    p = Paginator()
    with pytest.raises(TypeError):
        p.paginate(results)