Skip to content

Continue adding tests #4

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 29, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 43 additions & 0 deletions python/tests/test_cursor.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,3 +62,46 @@ async def test_cursor_fetch_last(
last_res = await test_cursor.fetch_last()

assert all_res.result()[-1] == last_res.result()[0]


@pytest.mark.anyio
async def test_cursor_fetch_absolute(
test_cursor: Cursor,
number_database_records: int,
) -> None:
"""Test cursor fetch Absolute."""
all_res = await test_cursor.fetch(
fetch_number=number_database_records,
)

first_record = await test_cursor.fetch_absolute(
absolute_number=1,
)
last_record = await test_cursor.fetch_absolute(
absolute_number=-1,
)

assert all_res.result()[0] == first_record.result()[0]
assert all_res.result()[-1] == last_record.result()[0]


@pytest.mark.anyio
async def test_cursor_fetch_relative(
test_cursor: Cursor,
number_database_records: int,
) -> None:
"""Test cursor fetch Relative."""
first_absolute = await test_cursor.fetch_relative(
relative_number=1,
)

assert first_absolute.result()

await test_cursor.fetch(
fetch_number=number_database_records,
)
records = await test_cursor.fetch_relative(
relative_number=1,
)

assert not (records.result())