11
11
12
12
from apify import Actor
13
13
from apify import Configuration as ApifyConfiguration
14
- from apify .storage_clients . _file_system import ApifyFileSystemStorageClient
14
+ from apify .storage_clients import FileSystemStorageClient as ApifyFileSystemStorageClient
15
15
16
16
17
17
@pytest .mark .parametrize (
@@ -177,7 +177,7 @@ async def test_crawler_uses_implicit_apify_config() -> None:
177
177
assert isinstance (Actor .configuration , ApifyConfiguration )
178
178
179
179
180
- async def test_storage_retrieved_is_different_with_different_config (tmp_path : Path ) -> None :
180
+ async def test_storages_retrieved_is_different_with_different_config (tmp_path : Path ) -> None :
181
181
"""Test that retrieving storage depends on used configuration."""
182
182
dir_1 = tmp_path / 'dir_1'
183
183
dir_2 = tmp_path / 'dir_2'
@@ -188,34 +188,55 @@ async def test_storage_retrieved_is_different_with_different_config(tmp_path: Pa
188
188
189
189
async with Actor (configuration = config_actor ):
190
190
actor_kvs = await Actor .open_key_value_store ()
191
+ actor_dataset = await Actor .open_dataset ()
192
+ actor_rq = await Actor .open_request_queue ()
193
+
191
194
crawler = BasicCrawler (configuration = config_crawler )
192
195
crawler_kvs = await crawler .get_key_value_store ()
196
+ crawler_dataset = await crawler .get_dataset ()
197
+ crawler_rq = await crawler .get_request_manager ()
193
198
194
199
assert actor_kvs is not crawler_kvs
200
+ assert actor_dataset is not crawler_dataset
201
+ assert actor_rq is not crawler_rq
195
202
196
203
197
- async def test_storage_retrieved_is_same_with_equivalent_config () -> None :
204
+ async def test_storages_retrieved_is_same_with_equivalent_config () -> None :
198
205
"""Test that retrieving storage depends on used configuration. If two equivalent configuration(even if they are
199
206
different instances) are used it returns same storage."""
200
207
config_actor = ApifyConfiguration ()
201
208
config_crawler = ApifyConfiguration ()
202
209
203
210
async with Actor (configuration = config_actor ):
204
211
actor_kvs = await Actor .open_key_value_store ()
212
+ actor_dataset = await Actor .open_dataset ()
213
+ actor_rq = await Actor .open_request_queue ()
214
+
205
215
crawler = BasicCrawler (configuration = config_crawler )
206
216
crawler_kvs = await crawler .get_key_value_store ()
217
+ crawler_dataset = await crawler .get_dataset ()
218
+ crawler_rq = await crawler .get_request_manager ()
207
219
208
220
assert actor_kvs is crawler_kvs
221
+ assert actor_dataset is crawler_dataset
222
+ assert actor_rq is crawler_rq
209
223
210
224
211
- async def test_storage_retrieved_is_same_with_same_config () -> None :
225
+ async def test_storages_retrieved_is_same_with_same_config () -> None :
212
226
"""Test that retrieving storage is same if same configuration is used."""
213
227
async with Actor ():
214
228
actor_kvs = await Actor .open_key_value_store ()
229
+ actor_dataset = await Actor .open_dataset ()
230
+ actor_rq = await Actor .open_request_queue ()
231
+
215
232
crawler = BasicCrawler ()
216
233
crawler_kvs = await crawler .get_key_value_store ()
234
+ crawler_dataset = await crawler .get_dataset ()
235
+ crawler_rq = await crawler .get_request_manager ()
217
236
218
237
assert actor_kvs is crawler_kvs
238
+ assert actor_dataset is crawler_dataset
239
+ assert actor_rq is crawler_rq
219
240
220
241
221
242
async def test_file_system_storage_client_warning (caplog : pytest .LogCaptureFixture ) -> None :
@@ -225,6 +246,7 @@ async def test_file_system_storage_client_warning(caplog: pytest.LogCaptureFixtu
225
246
...
226
247
227
248
assert (
228
- 'Using `FileSystemStorageClient` in Actor context is not recommended and can lead to problems with reading '
229
- 'the input file. Use `ApifyFileSystemStorageClient` instead.'
249
+ 'Using crawlee.storage_clients._file_system._storage_client.FileSystemStorageClient in Actor context is not '
250
+ 'recommended and can lead to problems with reading the input file. Use '
251
+ '`apify.storage_clients.FileSystemStorageClient` instead.'
230
252
) in caplog .messages
0 commit comments