Skip to content

Commit 89480b3

Browse files
committed
Add error hint when opening non-existent local storage
1 parent b916f7d commit 89480b3

File tree

4 files changed

+30
-1
lines changed

4 files changed

+30
-1
lines changed

src/apify/_actor.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,9 @@ async def wrapper(
6565
return await function(self=self, id=id, name=name, force_cloud=force_cloud)
6666
except Exception as e:
6767
if not force_cloud:
68-
e.args = (f'{e.args[0]} (If you are trying to retrieve a remote storage, use `force_cloud=True`.)',)
68+
e.args = (
69+
f'{e.args[0]} (If you are trying to retrieve a remote storage, use `force_cloud=True` argument.)',
70+
)
6971
raise
7072

7173
return cast(TFun, wrapper)

tests/unit/actor/test_actor_dataset.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,3 +62,12 @@ async def test_push_data_to_dataset() -> None:
6262

6363
list_page = await dataset.get_data(limit=desired_item_count)
6464
assert {item['id'] for item in list_page.items} == set(range(desired_item_count))
65+
66+
67+
async def test_open_local_non_existent_dataset() -> None:
68+
async with Actor as my_actor:
69+
with pytest.raises(RuntimeError) as e:
70+
await my_actor.open_dataset(id='non-existent')
71+
assert str(e.value).endswith(
72+
'If you are trying to retrieve a remote storage, use `force_cloud=True` argument.)'
73+
)

tests/unit/actor/test_actor_key_value_store.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,3 +92,12 @@ async def test_get_input_with_encrypted_secrets(
9292
input = await my_actor.get_input() # noqa: A001
9393
assert input['foo'] == input_with_secret['foo']
9494
assert input['secret'] == secret_string
95+
96+
97+
async def test_open_local_non_existent_kvs() -> None:
98+
async with Actor as my_actor:
99+
with pytest.raises(RuntimeError) as e:
100+
await my_actor.open_key_value_store(id='non-existent')
101+
assert str(e.value).endswith(
102+
'If you are trying to retrieve a remote storage, use `force_cloud=True` argument.)'
103+
)

tests/unit/actor/test_actor_request_queue.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,3 +27,12 @@ async def test_open_returns_same_references() -> None:
2727
rq_by_id_2 = await Actor.open_key_value_store(id=rq_by_name_1._id)
2828
assert rq_by_id_1 is rq_by_name_1
2929
assert rq_by_id_2 is rq_by_id_1
30+
31+
32+
async def test_open_local_non_existent_rq() -> None:
33+
async with Actor as my_actor:
34+
with pytest.raises(RuntimeError) as e:
35+
await my_actor.open_request_queue(id='non-existent')
36+
assert str(e.value).endswith(
37+
'If you are trying to retrieve a remote storage, use `force_cloud=True` argument.)'
38+
)

0 commit comments

Comments
 (0)