Skip to content

Commit 14bc01b

Browse files
committed
Fixes
1 parent 6f20183 commit 14bc01b

File tree

5 files changed

+36
-15
lines changed

5 files changed

+36
-15
lines changed

tests/integration/actor/test_actor_api_helpers.py

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -293,9 +293,14 @@ async def main_outer() -> None:
293293

294294
assert run_result_outer.status == 'SUCCEEDED'
295295

296-
await inner_actor.last_run().wait_for_finish(wait_secs=600)
297-
inner_actor_last_run_dict = await inner_actor.last_run().get()
298-
inner_actor_last_run = ActorRun.model_validate(inner_actor_last_run_dict)
296+
inner_actor_run_client = inner_actor.last_run()
297+
inner_actor_run = await inner_actor_run_client.wait_for_finish(wait_secs=600)
298+
299+
if inner_actor_run is None:
300+
raise AssertionError('Failed to get inner actor run after aborting it.')
301+
302+
inner_actor_run_dict = inner_actor_run.model_dump(by_alias=True)
303+
inner_actor_last_run = ActorRun.model_validate(inner_actor_run_dict)
299304

300305
assert inner_actor_last_run.status == 'ABORTED'
301306

@@ -471,8 +476,14 @@ async def main_client() -> None:
471476

472477
assert ac_run_result.status == 'SUCCEEDED'
473478

474-
sa_run_result_dict = await server_actor.last_run().wait_for_finish(wait_secs=600)
475-
sa_run_result = ActorRun.model_validate(sa_run_result_dict)
479+
sa_run_client = server_actor.last_run()
480+
sa_run_client_run = await sa_run_client.wait_for_finish(wait_secs=600)
481+
482+
if sa_run_client_run is None:
483+
raise AssertionError('Failed to get server actor run after waiting for finish.')
484+
485+
sa_run_client_run_dict = sa_run_client_run.model_dump(by_alias=True)
486+
sa_run_result = ActorRun.model_validate(sa_run_client_run_dict)
476487

477488
assert sa_run_result.status == 'SUCCEEDED'
478489

tests/integration/actor/test_actor_charge.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,8 @@ async def test_actor_charge_basic(
8484
for is_last_attempt, _ in retry_counter(30):
8585
await asyncio.sleep(1)
8686

87-
updated_run = await apify_client_async.run(run.id).get()
87+
run_client = apify_client_async.run(run.id)
88+
updated_run = await run_client.get()
8889
assert updated_run is not None, 'Updated run should not be None'
8990

9091
updated_run_dict = updated_run.model_dump(by_alias=True)
@@ -110,7 +111,8 @@ async def test_actor_charge_limit(
110111
for is_last_attempt, _ in retry_counter(30):
111112
await asyncio.sleep(1)
112113

113-
updated_run = await apify_client_async.run(run.id).get()
114+
run_client = apify_client_async.run(run.id)
115+
updated_run = await run_client.get()
114116
assert updated_run is not None, 'Updated run should not be None'
115117

116118
updated_run_dict = updated_run.model_dump(by_alias=True)

tests/integration/actor/test_actor_request_queue.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -306,8 +306,15 @@ async def main() -> None:
306306
# Redirect logs even from the resurrected run
307307
streamed_log = await run_client.get_streamed_log(from_start=False)
308308
await run_client.resurrect()
309+
309310
async with streamed_log:
310-
run_result = ActorRun.model_validate(await run_client.wait_for_finish(wait_secs=600))
311+
run = await run_client.wait_for_finish(wait_secs=600)
312+
313+
if run is None:
314+
raise AssertionError('Failed to get resurrected run.')
315+
316+
run_dict = run.model_dump(by_alias=True)
317+
run_result = ActorRun.model_validate(run_dict)
311318
assert run_result.status == 'SUCCEEDED'
312319

313320

tests/integration/apify_api/test_request_queue.py

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

99
import pytest
1010

11+
from apify_client._models import Data13, ProcessedRequest, UnprocessedRequest
1112
from apify_shared.consts import ApifyEnvVars
1213
from crawlee import service_locator
1314
from crawlee.crawlers import BasicCrawler
@@ -1168,15 +1169,15 @@ async def test_request_queue_deduplication_unprocessed_requests(
11681169
assert stats_before is not None
11691170
assert stats_before.write_count is not None
11701171

1171-
def return_unprocessed_requests(requests: list[dict], *_: Any, **__: Any) -> dict[str, list[dict]]:
1172+
def return_unprocessed_requests(requests: list[dict], *_: Any, **__: Any) -> Data13:
11721173
"""Simulate API returning unprocessed requests."""
1173-
return {
1174-
'processedRequests': [],
1175-
'unprocessedRequests': [
1176-
{'url': request['url'], 'uniqueKey': request['uniqueKey'], 'method': request['method']}
1174+
return Data13(
1175+
processed_requests=list[ProcessedRequest](),
1176+
unprocessed_requests=[
1177+
UnprocessedRequest(url=request['url'], unique_key=request['uniqueKey'], method=request['method'])
11771178
for request in requests
11781179
],
1179-
}
1180+
)
11801181

11811182
with mock.patch(
11821183
'apify_client._resource_clients.request_queue.RequestQueueClientAsync.batch_add_requests',

uv.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)