@@ -105,3 +105,53 @@ async def test_cursor_fetch_relative(
105
105
)
106
106
107
107
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