File tree Expand file tree Collapse file tree 3 files changed +8
-6
lines changed Expand file tree Collapse file tree 3 files changed +8
-6
lines changed Original file line number Diff line number Diff line change 8
8
from pathlib import Path
9
9
10
10
import osparc
11
+ from osparc ._utils import PaginationIterator
11
12
import pytest
12
13
from memory_profiler import memory_usage
13
14
from typing import Final , List , Callable
@@ -96,7 +97,7 @@ def test_search_files(
96
97
use_id : bool ,
97
98
faker : Faker ,
98
99
) -> None :
99
- results : osparc . PaginationGenerator = files_api ._search_files (
100
+ results : PaginationIterator = files_api ._search_files (
100
101
sha256_checksum = f"{ faker .sha256 ()} "
101
102
)
102
103
assert len (results ) == 0 , "Found file which shouldn't be there"
@@ -108,5 +109,5 @@ def test_search_files(
108
109
else None ,
109
110
)
110
111
assert len (results ) == 1 , "Could not find file after it had been uploaded"
111
- for file in results :
112
- assert file .checksum == large_server_file .server_file .checksum
112
+ file = next ( results )
113
+ assert file .checksum == large_server_file .server_file .checksum
Original file line number Diff line number Diff line change @@ -38,7 +38,7 @@ def page_file(faker: Faker) -> osparc.PageFile:
38
38
39
39
return osparc .PageFile (
40
40
items = items ,
41
- total = faker .pyint (min_value = 1 , max_value = 10 ) * len (items ),
41
+ total = faker .pyint (min_value = len ( items ) + 1 , max_value = len (items ) + 100 ),
42
42
limit = len (items ),
43
43
offset = faker .pyint (min_value = 0 ),
44
44
links = osparc .Links (next = faker .url ()),
Original file line number Diff line number Diff line change @@ -106,9 +106,10 @@ def test_pagination_iterator(
106
106
)
107
107
108
108
def _sideeffect (all_items : List , request : httpx .Request ):
109
- if len (all_items ) > faker .pyint (min_value = 10 ):
110
- page_file .links .next = None
111
109
all_items += page_file .items
110
+ if len (all_items ) >= page_file .total :
111
+ all_items = all_items [: page_file .total ]
112
+ page_file .links .next = None
112
113
return httpx .Response (status_code = 200 , json = page_file .to_dict ())
113
114
114
115
with respx .mock (
You can’t perform that action at this time.
0 commit comments