Skip to content

Commit cac48e5

Browse files
authored
chore: upgrade apify-client to v3 for e2e tests (#2304)
Moves the e2e tests to apify-client v3, now that Python 3.10 is gone. The dev pin goes from `<3.0.0` to `<4.0.0`, and the template e2e test uses the v3 API: model attributes instead of dict keys, and `wait_duration=timedelta(...)` instead of `wait_secs`. Closes: #2303 *✍️ Drafted by Claude Code*
1 parent fbf199c commit cac48e5

3 files changed

Lines changed: 47 additions & 29 deletions

File tree

‎pyproject.toml‎

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -120,9 +120,7 @@ dev = [
120120
# We explicitly constrain black>=24.3.0 to override the transitive dependency.
121121
"black>=24.3.0",
122122
"anyio<5.0.0",
123-
# Pin below 3.0, which drops Python 3.10 support and introduces a breaking API. Once Crawlee
124-
# drops Python 3.10 (https://github.com/apify/crawlee-python/issues/1721), remove this constraint.
125-
"apify_client<3.0.0", # For e2e tests.
123+
"apify_client<4.0.0", # For e2e tests.
126124
"build<2.0.0", # For e2e tests.
127125
"fakeredis[probabilistic,json,lua]<3.0.0",
128126
"poethepoet<1.0.0",

‎tests/e2e/project_template/test_static_crawlers_templates.py‎

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import os
22
import re
33
import subprocess
4+
from datetime import timedelta
45
from pathlib import Path
56
from typing import Literal
67

@@ -137,15 +138,15 @@ async def test_static_crawler_actor_at_apify(
137138
# then poll client-side via `BuildClientAsync.wait_for_finish` until it reaches a terminal
138139
# status, and assert it succeeded before starting the run.
139140
rebuild = await actor.build(version_number='0.0')
140-
finished_build = await client.build(rebuild['id']).wait_for_finish(wait_secs=900)
141+
finished_build = await client.build(rebuild.id).wait_for_finish(wait_duration=timedelta(seconds=900))
141142
assert finished_build is not None, 'Stagehand rebuild did not reach a terminal status within 900s.'
142-
assert finished_build['status'] == 'SUCCEEDED', (
143-
f'Stagehand rebuild did not succeed: status={finished_build["status"]!r}, build={finished_build}'
143+
assert finished_build.status == 'SUCCEEDED', (
144+
f'Stagehand rebuild did not succeed: status={finished_build.status!r}, build={finished_build}'
144145
)
145-
build_number = finished_build['buildNumber']
146+
build_number = finished_build.build_number
146147

147148
started_run_data = await actor.start(memory_mbytes=8192, build=build_number)
148-
actor_run = client.run(started_run_data['id'])
149+
actor_run = client.run(started_run_data.id)
149150

150151
finished_run_data = await actor_run.wait_for_finish()
151152
actor_run_log = await actor_run.log().get()
@@ -157,7 +158,7 @@ async def test_static_crawler_actor_at_apify(
157158
additional_run_info = f'Full actor run log: {actor_run_log}'
158159
assert actor_run_log
159160
assert finished_run_data
160-
assert finished_run_data['status'] == 'SUCCEEDED', additional_run_info
161+
assert finished_run_data.status == 'SUCCEEDED', additional_run_info
161162
assert (
162163
'Crawler.stop() was called with following reason: The crawler has reached its limit of 10 requests per crawl.'
163164
) in actor_run_log, additional_run_info

‎uv.lock‎

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

0 commit comments

Comments
 (0)