Skip to content

Commit bbf4e8e

Browse files
committed
Resolve pytest warnings
1 parent 1b35b96 commit bbf4e8e

File tree

7 files changed

+32
-30
lines changed

7 files changed

+32
-30
lines changed

tests/integration/conftest.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import pytest
66
from apify_shared.utils import create_hmac_signature, create_storage_content_signature
77

8-
from .utils import TestDataset, TestKvs, get_crypto_random_object_id
8+
from .utils import DatasetFixture, KvsFixture, get_crypto_random_object_id
99
from apify_client import ApifyClient, ApifyClientAsync
1010

1111
TOKEN_ENV_VAR = 'APIFY_TEST_USER_API_TOKEN'
@@ -46,7 +46,7 @@ def apify_client_async(api_token: str) -> ApifyClientAsync:
4646

4747

4848
@pytest.fixture(scope='session')
49-
def test_dataset_of_another_user(api_token_2: str) -> Generator[TestDataset]:
49+
def test_dataset_of_another_user(api_token_2: str) -> Generator[DatasetFixture]:
5050
"""Pre-existing named dataset of another test user with restricted access."""
5151
client = ApifyClient(api_token_2, api_url=os.getenv(API_URL_ENV_VAR))
5252

@@ -66,7 +66,7 @@ def test_dataset_of_another_user(api_token_2: str) -> Generator[TestDataset]:
6666
url_signing_secret_key=dataset.url_signing_secret_key,
6767
)
6868

69-
yield TestDataset(
69+
yield DatasetFixture(
7070
id=dataset.id,
7171
signature=signature,
7272
expected_content=[{'item1': 1, 'item2': 2, 'item3': 3}, {'item1': 4, 'item2': 5, 'item3': 6}],
@@ -76,7 +76,7 @@ def test_dataset_of_another_user(api_token_2: str) -> Generator[TestDataset]:
7676

7777

7878
@pytest.fixture(scope='session')
79-
def test_kvs_of_another_user(api_token_2: str) -> Generator[TestKvs]:
79+
def test_kvs_of_another_user(api_token_2: str) -> Generator[KvsFixture]:
8080
"""Pre-existing named key value store of another test user with restricted access."""
8181
client = ApifyClient(api_token_2, api_url=os.getenv(API_URL_ENV_VAR))
8282

@@ -94,7 +94,7 @@ def test_kvs_of_another_user(api_token_2: str) -> Generator[TestKvs]:
9494
resource_id=kvs.id, url_signing_secret_key=kvs.url_signing_secret_key or ''
9595
)
9696

97-
yield TestKvs(
97+
yield KvsFixture(
9898
id=kvs.id,
9999
signature=signature,
100100
expected_content=expected_content,

tests/integration/test_dataset.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
import impit
99
import pytest
1010

11-
from .utils import TestDataset, get_random_resource_name, parametrized_api_urls
11+
from .utils import DatasetFixture, get_random_resource_name, parametrized_api_urls
1212
from apify_client import ApifyClient
1313
from apify_client._client import DEFAULT_API_URL
1414
from apify_client.errors import ApifyApiError
@@ -100,7 +100,7 @@ def test_public_url(api_token: str, api_url: str, api_public_url: str) -> None:
100100
)
101101

102102

103-
def test_list_items_signature(apify_client: ApifyClient, test_dataset_of_another_user: TestDataset) -> None:
103+
def test_list_items_signature(apify_client: ApifyClient, test_dataset_of_another_user: DatasetFixture) -> None:
104104
dataset = apify_client.dataset(dataset_id=test_dataset_of_another_user.id)
105105

106106
# Permission error without valid signature
@@ -118,7 +118,7 @@ def test_list_items_signature(apify_client: ApifyClient, test_dataset_of_another
118118
)
119119

120120

121-
def test_iterate_items_signature(apify_client: ApifyClient, test_dataset_of_another_user: TestDataset) -> None:
121+
def test_iterate_items_signature(apify_client: ApifyClient, test_dataset_of_another_user: DatasetFixture) -> None:
122122
dataset = apify_client.dataset(dataset_id=test_dataset_of_another_user.id)
123123

124124
# Permission error without valid signature
@@ -135,7 +135,7 @@ def test_iterate_items_signature(apify_client: ApifyClient, test_dataset_of_anot
135135
)
136136

137137

138-
def test_get_items_as_bytes_signature(apify_client: ApifyClient, test_dataset_of_another_user: TestDataset) -> None:
138+
def test_get_items_as_bytes_signature(apify_client: ApifyClient, test_dataset_of_another_user: DatasetFixture) -> None:
139139
dataset = apify_client.dataset(dataset_id=test_dataset_of_another_user.id)
140140

141141
# Permission error without valid signature

tests/integration/test_dataset_async.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
import impit
99
import pytest
1010

11-
from .utils import TestDataset, get_random_resource_name, parametrized_api_urls
11+
from .utils import DatasetFixture, get_random_resource_name, parametrized_api_urls
1212
from apify_client import ApifyClientAsync
1313
from apify_client._client import DEFAULT_API_URL
1414
from apify_client.errors import ApifyApiError
@@ -103,7 +103,7 @@ async def test_public_url(api_token: str, api_url: str, api_public_url: str) ->
103103

104104

105105
async def test_list_items_signature(
106-
apify_client_async: ApifyClientAsync, test_dataset_of_another_user: TestDataset
106+
apify_client_async: ApifyClientAsync, test_dataset_of_another_user: DatasetFixture
107107
) -> None:
108108
dataset = apify_client_async.dataset(dataset_id=test_dataset_of_another_user.id)
109109

@@ -123,7 +123,7 @@ async def test_list_items_signature(
123123

124124

125125
async def test_iterate_items_signature(
126-
apify_client_async: ApifyClientAsync, test_dataset_of_another_user: TestDataset
126+
apify_client_async: ApifyClientAsync, test_dataset_of_another_user: DatasetFixture
127127
) -> None:
128128
dataset = apify_client_async.dataset(dataset_id=test_dataset_of_another_user.id)
129129

@@ -142,7 +142,7 @@ async def test_iterate_items_signature(
142142

143143

144144
async def test_get_items_as_bytes_signature(
145-
apify_client_async: ApifyClientAsync, test_dataset_of_another_user: TestDataset
145+
apify_client_async: ApifyClientAsync, test_dataset_of_another_user: DatasetFixture
146146
) -> None:
147147
dataset = apify_client_async.dataset(dataset_id=test_dataset_of_another_user.id)
148148

tests/integration/test_key_value_store.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
import pytest
1010
from apify_shared.utils import create_hmac_signature, create_storage_content_signature
1111

12-
from .utils import TestKvs, get_random_resource_name, parametrized_api_urls
12+
from .utils import KvsFixture, get_random_resource_name, parametrized_api_urls
1313
from apify_client import ApifyClient
1414
from apify_client._client import DEFAULT_API_URL
1515
from apify_client.errors import ApifyApiError
@@ -131,7 +131,7 @@ def test_record_public_url(api_token: str, api_url: str, api_public_url: str, si
131131
)
132132

133133

134-
def test_list_keys_signature(apify_client: ApifyClient, test_kvs_of_another_user: TestKvs) -> None:
134+
def test_list_keys_signature(apify_client: ApifyClient, test_kvs_of_another_user: KvsFixture) -> None:
135135
kvs = apify_client.key_value_store(key_value_store_id=test_kvs_of_another_user.id)
136136

137137
# Permission error without valid signature
@@ -149,7 +149,7 @@ def test_list_keys_signature(apify_client: ApifyClient, test_kvs_of_another_user
149149
assert set(test_kvs_of_another_user.expected_content) == {item.key for item in raw_items}
150150

151151

152-
def test_get_record_signature(apify_client: ApifyClient, test_kvs_of_another_user: TestKvs) -> None:
152+
def test_get_record_signature(apify_client: ApifyClient, test_kvs_of_another_user: KvsFixture) -> None:
153153
key = 'key1'
154154
kvs = apify_client.key_value_store(key_value_store_id=test_kvs_of_another_user.id)
155155

@@ -167,7 +167,7 @@ def test_get_record_signature(apify_client: ApifyClient, test_kvs_of_another_use
167167
assert test_kvs_of_another_user.expected_content[key] == record['value']
168168

169169

170-
def test_get_record_as_bytes_signature(apify_client: ApifyClient, test_kvs_of_another_user: TestKvs) -> None:
170+
def test_get_record_as_bytes_signature(apify_client: ApifyClient, test_kvs_of_another_user: KvsFixture) -> None:
171171
key = 'key1'
172172
kvs = apify_client.key_value_store(key_value_store_id=test_kvs_of_another_user.id)
173173

@@ -185,7 +185,7 @@ def test_get_record_as_bytes_signature(apify_client: ApifyClient, test_kvs_of_an
185185
assert test_kvs_of_another_user.expected_content[key] == json.loads(item['value'].decode('utf-8'))
186186

187187

188-
def test_stream_record_signature(apify_client: ApifyClient, test_kvs_of_another_user: TestKvs) -> None:
188+
def test_stream_record_signature(apify_client: ApifyClient, test_kvs_of_another_user: KvsFixture) -> None:
189189
key = 'key1'
190190
kvs = apify_client.key_value_store(key_value_store_id=test_kvs_of_another_user.id)
191191

tests/integration/test_key_value_store_async.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
import pytest
1010
from apify_shared.utils import create_hmac_signature, create_storage_content_signature
1111

12-
from .utils import TestKvs, get_random_resource_name, parametrized_api_urls
12+
from .utils import KvsFixture, get_random_resource_name, parametrized_api_urls
1313
from apify_client import ApifyClientAsync
1414
from apify_client._client import DEFAULT_API_URL
1515
from apify_client.errors import ApifyApiError
@@ -137,7 +137,7 @@ async def test_record_public_url(api_token: str, api_url: str, api_public_url: s
137137
)
138138

139139

140-
async def test_list_keys_signature(apify_client_async: ApifyClientAsync, test_kvs_of_another_user: TestKvs) -> None:
140+
async def test_list_keys_signature(apify_client_async: ApifyClientAsync, test_kvs_of_another_user: KvsFixture) -> None:
141141
kvs = apify_client_async.key_value_store(key_value_store_id=test_kvs_of_another_user.id)
142142

143143
# Permission error without valid signature
@@ -155,7 +155,7 @@ async def test_list_keys_signature(apify_client_async: ApifyClientAsync, test_kv
155155
assert set(test_kvs_of_another_user.expected_content) == {item.key for item in raw_items}
156156

157157

158-
async def test_get_record_signature(apify_client_async: ApifyClientAsync, test_kvs_of_another_user: TestKvs) -> None:
158+
async def test_get_record_signature(apify_client_async: ApifyClientAsync, test_kvs_of_another_user: KvsFixture) -> None:
159159
key = 'key1'
160160
kvs = apify_client_async.key_value_store(key_value_store_id=test_kvs_of_another_user.id)
161161

@@ -174,7 +174,7 @@ async def test_get_record_signature(apify_client_async: ApifyClientAsync, test_k
174174

175175

176176
async def test_get_record_as_bytes_signature(
177-
apify_client_async: ApifyClientAsync, test_kvs_of_another_user: TestKvs
177+
apify_client_async: ApifyClientAsync, test_kvs_of_another_user: KvsFixture
178178
) -> None:
179179
key = 'key1'
180180
kvs = apify_client_async.key_value_store(key_value_store_id=test_kvs_of_another_user.id)
@@ -193,7 +193,10 @@ async def test_get_record_as_bytes_signature(
193193
assert test_kvs_of_another_user.expected_content[key] == json.loads(item['value'].decode('utf-8'))
194194

195195

196-
async def test_stream_record_signature(apify_client_async: ApifyClientAsync, test_kvs_of_another_user: TestKvs) -> None:
196+
async def test_stream_record_signature(
197+
apify_client_async: ApifyClientAsync,
198+
test_kvs_of_another_user: KvsFixture,
199+
) -> None:
197200
key = 'key1'
198201
kvs = apify_client_async.key_value_store(key_value_store_id=test_kvs_of_another_user.id)
199202

tests/integration/utils.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,23 +7,23 @@
77

88

99
@dataclasses.dataclass
10-
class TestStorage:
11-
"""Test storage resource with ID and signature."""
10+
class StorageFixture:
11+
"""Storage resource fixture with ID and signature."""
1212

1313
id: str
1414
signature: str
1515

1616

1717
@dataclasses.dataclass
18-
class TestDataset(TestStorage):
19-
"""Test dataset with expected content."""
18+
class DatasetFixture(StorageFixture):
19+
"""Dataset fixture with expected content."""
2020

2121
expected_content: list
2222

2323

2424
@dataclasses.dataclass
25-
class TestKvs(TestStorage):
26-
"""Test key-value store with expected content and key signatures."""
25+
class KvsFixture(StorageFixture):
26+
"""Key-value store fixture with expected content and key signatures."""
2727

2828
expected_content: dict[str, Any]
2929
keys_signature: dict[str, str]

tests/unit/test_client_timeouts.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,6 @@ def mock_request(*_args: Any, **kwargs: Any) -> Response:
122122
(DatasetClient, 'update', dataset._SMALL_TIMEOUT, {}),
123123
(DatasetClient, 'delete', dataset._SMALL_TIMEOUT, {}),
124124
(DatasetClient, 'list_items', DEFAULT_TIMEOUT, {}),
125-
(DatasetClient, 'download_items', DEFAULT_TIMEOUT, {}),
126125
(DatasetClient, 'get_items_as_bytes', DEFAULT_TIMEOUT, {}),
127126
(DatasetClient, 'push_items', dataset._MEDIUM_TIMEOUT, {'items': {}}),
128127
(DatasetClient, 'get_statistics', dataset._SMALL_TIMEOUT, {}),

0 commit comments

Comments
 (0)