コード例 #1
0
async def test_since_id():
    MockIteratorRequest.kwargs = dict(since_id=499, count=10)
    responses = iterators.with_since_id(MockIteratorRequest,
                                        fill_gaps=False,
                                        force=False)

    ids = set()
    async for response in responses:
        new_ids = {user['id'] for user in response}
        size_before = len(ids)
        ids |= new_ids

        if len(ids) != len(new_ids) + size_before or len(ids) > 10:
            print(new_ids)
            break

    assert len(ids) == 10
コード例 #2
0
async def test_fill_gaps():
    MockIteratorRequest.kwargs = dict(since_id=499)
    responses = iterators.with_since_id(MockIteratorRequest,
                                        fill_gaps=True,
                                        force=False)

    ids = set()
    async for response in responses:
        new_ids = {user['id'] for user in response}
        ids |= new_ids

        if len(new_ids) == 0:
            raise AssertionError("Iteration should have stopped here")

        if len(ids) > 500:
            break

    assert len(ids) == 500
コード例 #3
0
async def test_fill_gaps_force():
    MockIteratorRequest.kwargs = dict(since_id=499)
    responses = iterators.with_since_id(MockIteratorRequest,
                                        fill_gaps=True,
                                        force=True)

    ids = set()
    async for response in responses:
        new_ids = {user['id'] for user in response}
        size_before = len(ids)
        ids |= new_ids

        if len(new_ids) == 0:
            break

        if len(ids) != len(new_ids) + size_before or len(ids) > 500:
            break

    assert len(ids) == 500
コード例 #4
0
async def test_since_id(dict_resp):
    MockIteratorRequest.kwargs = dict(since_id=499, count=10, dict=dict_resp)
    responses = iterators.with_since_id(MockIteratorRequest,
                                        fill_gaps=False,
                                        force=False)

    ids = set()
    async for response in responses:
        if dict_resp:
            response = response['statuses']

        new_ids = {user['id'] for user in response}
        size_before = len(ids)
        ids |= new_ids

        assert len(new_ids) > 0

        if len(ids) != len(new_ids) + size_before or len(ids) > 10:
            break

    assert len(ids) == 10