Skip to content

Commit b67fbbe

Browse files
authored
test: Fix integration test failures caused by limited permissions (#733)
Closes: #715
1 parent ed35b6d commit b67fbbe

File tree

4 files changed

+15
-11
lines changed

4 files changed

+15
-11
lines changed

tests/integration/actor/conftest.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
from filelock import FileLock
1414

1515
from apify_client import ApifyClient, ApifyClientAsync
16-
from apify_shared.consts import ActorJobStatus, ActorSourceType
16+
from apify_shared.consts import ActorJobStatus, ActorPermissionLevel, ActorSourceType
1717

1818
from .._utils import generate_unique_resource_name
1919
from apify._models import ActorRun
@@ -280,12 +280,14 @@ def __call__(
280280
*,
281281
run_input: Any = None,
282282
max_total_charge_usd: Decimal | None = None,
283+
force_permission_level: ActorPermissionLevel | None = None,
283284
) -> Coroutine[None, None, ActorRun]:
284285
"""Initiate an Actor run and wait for its completion.
285286
286287
Args:
287288
actor: Actor async client, in testing context usually created by `make_actor` fixture.
288289
run_input: Optional input for the Actor run.
290+
force_permission_level: Override the Actor's permissions for this run.
289291
290292
Returns:
291293
Actor run result.
@@ -305,10 +307,12 @@ async def _run_actor(
305307
*,
306308
run_input: Any = None,
307309
max_total_charge_usd: Decimal | None = None,
310+
force_permission_level: ActorPermissionLevel | None = None,
308311
) -> ActorRun:
309312
call_result = await actor.call(
310313
run_input=run_input,
311314
max_total_charge_usd=max_total_charge_usd,
315+
force_permission_level=force_permission_level,
312316
)
313317

314318
assert isinstance(call_result, dict), 'The result of ActorClientAsync.call() is not a dictionary.'

tests/integration/actor/test_actor_api_helpers.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,7 @@
44
import json
55
from typing import TYPE_CHECKING
66

7-
import pytest
8-
7+
from apify_shared.consts import ActorPermissionLevel
98
from crawlee._utils.crypto import crypto_random_object_id
109

1110
from .._utils import generate_unique_resource_name
@@ -197,7 +196,6 @@ async def main_outer() -> None:
197196
assert inner_output_record['value'] == f'{test_value}_XXX_{test_value}'
198197

199198

200-
@pytest.mark.skip(reason='Requires Actor permissions beyond limited permissions, see #715.')
201199
async def test_actor_calls_task(
202200
make_actor: MakeActorFunction,
203201
run_actor: RunActorFunction,
@@ -238,6 +236,7 @@ async def main_outer() -> None:
238236
run_result_outer = await run_actor(
239237
outer_actor,
240238
run_input={'test_value': test_value, 'inner_task_id': task['id']},
239+
force_permission_level=ActorPermissionLevel.FULL_PERMISSIONS,
241240
)
242241

243242
assert run_result_outer.status == 'SUCCEEDED'
@@ -251,7 +250,6 @@ async def main_outer() -> None:
251250
await apify_client_async.task(task['id']).delete()
252251

253252

254-
@pytest.mark.skip(reason='Requires Actor permissions beyond limited permissions, see #715.')
255253
async def test_actor_aborts_another_actor_run(
256254
make_actor: MakeActorFunction,
257255
run_actor: RunActorFunction,
@@ -274,11 +272,13 @@ async def main_outer() -> None:
274272
inner_actor = await make_actor(label='abort-inner', main_func=main_inner)
275273
outer_actor = await make_actor(label='abort-outer', main_func=main_outer)
276274

277-
inner_run_id = (await inner_actor.start())['id']
275+
run_result_inner = await inner_actor.start(force_permission_level=ActorPermissionLevel.FULL_PERMISSIONS)
276+
inner_run_id = run_result_inner['id']
278277

279278
run_result_outer = await run_actor(
280279
outer_actor,
281280
run_input={'inner_run_id': inner_run_id},
281+
force_permission_level=ActorPermissionLevel.FULL_PERMISSIONS,
282282
)
283283

284284
assert run_result_outer.status == 'SUCCEEDED'

tests/integration/actor/test_actor_scrapy.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,12 @@
33
from pathlib import Path
44
from typing import TYPE_CHECKING
55

6-
import pytest
6+
from apify_shared.consts import ActorPermissionLevel
77

88
if TYPE_CHECKING:
99
from .conftest import MakeActorFunction, RunActorFunction
1010

1111

12-
@pytest.mark.skip(reason='Requires Actor permissions beyond limited permissions, see #715.')
1312
async def test_actor_scrapy_title_spider(
1413
make_actor: MakeActorFunction,
1514
run_actor: RunActorFunction,
@@ -38,6 +37,7 @@ async def test_actor_scrapy_title_spider(
3837
'allowedDomains': ['crawlee.dev'],
3938
'proxyConfiguration': {'useApifyProxy': True},
4039
},
40+
force_permission_level=ActorPermissionLevel.FULL_PERMISSIONS,
4141
)
4242

4343
assert run_result.status == 'SUCCEEDED'

uv.lock

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)