Skip to content

Commit 31e5415

Browse files
authored
Merge pull request #5 from qaspen-python/feature/add_tests
Continue adding tests
2 parents a6e6e28 + 0803087 commit 31e5415

File tree

2 files changed

+53
-0
lines changed

2 files changed

+53
-0
lines changed

pyproject.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,9 @@ documentation = "https://github.com/qaspen-python/psqlpy/blob/main/README.md"
4343
profile = "black"
4444
multi_line_output = 3
4545

46+
[tool.black]
47+
line-length = 79
48+
4649
[tool.mypy]
4750
strict = true
4851
mypy_path = "python"

python/tests/test_cursor.py

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,3 +105,53 @@ async def test_cursor_fetch_relative(
105105
)
106106

107107
assert not (records.result())
108+
109+
110+
@pytest.mark.anyio
111+
async def test_cursor_fetch_forward_all(
112+
test_cursor: Cursor,
113+
number_database_records: int,
114+
) -> None:
115+
"""Test that cursor execute FETCH FORWARD ALL correctly."""
116+
default_fetch_number = 2
117+
await test_cursor.fetch(fetch_number=default_fetch_number)
118+
119+
rest_results = await test_cursor.fetch_forward_all()
120+
121+
assert (
122+
len(rest_results.result())
123+
== number_database_records - default_fetch_number
124+
)
125+
126+
127+
@pytest.mark.anyio
128+
async def test_cursor_fetch_backward(
129+
test_cursor: Cursor,
130+
) -> None:
131+
"""Test cursor backward fetch."""
132+
must_be_empty = await test_cursor.fetch_backward(backward_count=10)
133+
assert not (must_be_empty.result())
134+
135+
default_fetch_number = 5
136+
await test_cursor.fetch(fetch_number=default_fetch_number)
137+
138+
expected_number_of_results = 3
139+
must_not_be_empty = await test_cursor.fetch_backward(
140+
backward_count=expected_number_of_results,
141+
)
142+
assert len(must_not_be_empty.result()) == expected_number_of_results
143+
144+
145+
@pytest.mark.anyio
146+
async def test_cursor_fetch_backward_all(
147+
test_cursor: Cursor,
148+
) -> None:
149+
"""Test cursor `fetch_backward_all`."""
150+
must_be_empty = await test_cursor.fetch_backward_all()
151+
assert not (must_be_empty.result())
152+
153+
default_fetch_number = 5
154+
await test_cursor.fetch(fetch_number=default_fetch_number)
155+
156+
must_not_be_empty = await test_cursor.fetch_backward_all()
157+
assert len(must_not_be_empty.result()) == default_fetch_number - 1

0 commit comments

Comments
 (0)