Skip to content

Commit b424c9b

Browse files
committed
Update test_configuration.py
1 parent 79b0ff7 commit b424c9b

File tree

2 files changed

+31
-8
lines changed

2 files changed

+31
-8
lines changed

src/apify/_actor.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -241,8 +241,9 @@ def _finalize_implicit_local_storage_client(self) -> StorageClient:
241241
self._local_storage_client = service_locator.get_storage_client()
242242
if type(self._local_storage_client) is FileSystemStorageClient:
243243
self.log.warning(
244-
'Using `FileSystemStorageClient` in Actor context is not recommended and can lead to '
245-
'problems with reading the input file. Use `ApifyFileSystemStorageClient` instead.'
244+
f'Using {FileSystemStorageClient.__module__}.{FileSystemStorageClient.__name__} in Actor context is not'
245+
f' recommended and can lead to problems with reading the input file. Use '
246+
f'`apify.storage_clients.FileSystemStorageClient` instead.'
246247
)
247248
return self._local_storage_client
248249

tests/unit/actor/test_configuration.py

Lines changed: 28 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
from apify import Actor
1313
from apify import Configuration as ApifyConfiguration
14-
from apify.storage_clients._file_system import ApifyFileSystemStorageClient
14+
from apify.storage_clients import FileSystemStorageClient as ApifyFileSystemStorageClient
1515

1616

1717
@pytest.mark.parametrize(
@@ -177,7 +177,7 @@ async def test_crawler_uses_implicit_apify_config() -> None:
177177
assert isinstance(Actor.configuration, ApifyConfiguration)
178178

179179

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:
181181
"""Test that retrieving storage depends on used configuration."""
182182
dir_1 = tmp_path / 'dir_1'
183183
dir_2 = tmp_path / 'dir_2'
@@ -188,34 +188,55 @@ async def test_storage_retrieved_is_different_with_different_config(tmp_path: Pa
188188

189189
async with Actor(configuration=config_actor):
190190
actor_kvs = await Actor.open_key_value_store()
191+
actor_dataset = await Actor.open_dataset()
192+
actor_rq = await Actor.open_request_queue()
193+
191194
crawler = BasicCrawler(configuration=config_crawler)
192195
crawler_kvs = await crawler.get_key_value_store()
196+
crawler_dataset = await crawler.get_dataset()
197+
crawler_rq = await crawler.get_request_manager()
193198

194199
assert actor_kvs is not crawler_kvs
200+
assert actor_dataset is not crawler_dataset
201+
assert actor_rq is not crawler_rq
195202

196203

197-
async def test_storage_retrieved_is_same_with_equivalent_config() -> None:
204+
async def test_storages_retrieved_is_same_with_equivalent_config() -> None:
198205
"""Test that retrieving storage depends on used configuration. If two equivalent configuration(even if they are
199206
different instances) are used it returns same storage."""
200207
config_actor = ApifyConfiguration()
201208
config_crawler = ApifyConfiguration()
202209

203210
async with Actor(configuration=config_actor):
204211
actor_kvs = await Actor.open_key_value_store()
212+
actor_dataset = await Actor.open_dataset()
213+
actor_rq = await Actor.open_request_queue()
214+
205215
crawler = BasicCrawler(configuration=config_crawler)
206216
crawler_kvs = await crawler.get_key_value_store()
217+
crawler_dataset = await crawler.get_dataset()
218+
crawler_rq = await crawler.get_request_manager()
207219

208220
assert actor_kvs is crawler_kvs
221+
assert actor_dataset is crawler_dataset
222+
assert actor_rq is crawler_rq
209223

210224

211-
async def test_storage_retrieved_is_same_with_same_config() -> None:
225+
async def test_storages_retrieved_is_same_with_same_config() -> None:
212226
"""Test that retrieving storage is same if same configuration is used."""
213227
async with Actor():
214228
actor_kvs = await Actor.open_key_value_store()
229+
actor_dataset = await Actor.open_dataset()
230+
actor_rq = await Actor.open_request_queue()
231+
215232
crawler = BasicCrawler()
216233
crawler_kvs = await crawler.get_key_value_store()
234+
crawler_dataset = await crawler.get_dataset()
235+
crawler_rq = await crawler.get_request_manager()
217236

218237
assert actor_kvs is crawler_kvs
238+
assert actor_dataset is crawler_dataset
239+
assert actor_rq is crawler_rq
219240

220241

221242
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
225246
...
226247

227248
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.'
230252
) in caplog.messages

0 commit comments

Comments
 (0)