Skip to content

Commit a0073db

Browse files
committed
Update tests acc to new version of client
1 parent 98f1a89 commit a0073db

File tree

8 files changed

+30
-30
lines changed

8 files changed

+30
-30
lines changed

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ dependencies = [
4444
dev = [
4545
"build ~= 1.2.0",
4646
"filelock ~= 3.14.0",
47-
"mypy ~= 1.7.0",
47+
"mypy ~= 1.10.0",
4848
"pre-commit ~= 3.5.0",
4949
"pydoc-markdown ~= 4.8.0",
5050
"pytest ~= 8.2.0",

tests/integration/test_actor_api_helpers.py

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ async def main() -> None:
7777
assert run_result is not None
7878
assert run_result['status'] == 'SUCCEEDED'
7979

80-
output_record = await actor.last_run().key_value_store().get_record('OUTPUT')
80+
output_record = await (await actor.last_run()).key_value_store().get_record('OUTPUT')
8181
assert output_record is not None
8282
assert output_record['value'] == 'TESTING-OUTPUT'
8383

@@ -125,7 +125,7 @@ async def main_outer() -> None:
125125

126126
await Actor.start(inner_actor_id, run_input={'test_value': test_value})
127127

128-
inner_run_status = await Actor.apify_client.actor(inner_actor_id).last_run().get()
128+
inner_run_status = await (await Actor.apify_client.actor(inner_actor_id).last_run()).get()
129129
assert inner_run_status is not None
130130
assert inner_run_status.get('status') in ['READY', 'RUNNING']
131131

@@ -140,9 +140,9 @@ async def main_outer() -> None:
140140
assert outer_run_result is not None
141141
assert outer_run_result['status'] == 'SUCCEEDED'
142142

143-
await inner_actor.last_run().wait_for_finish()
143+
await (await inner_actor.last_run()).wait_for_finish()
144144

145-
inner_output_record = await inner_actor.last_run().key_value_store().get_record('OUTPUT')
145+
inner_output_record = await (await inner_actor.last_run()).key_value_store().get_record('OUTPUT')
146146
assert inner_output_record is not None
147147
assert inner_output_record['value'] == f'{test_value}_XXX_{test_value}'
148148

@@ -181,9 +181,9 @@ async def main_outer() -> None:
181181
assert outer_run_result is not None
182182
assert outer_run_result['status'] == 'SUCCEEDED'
183183

184-
await inner_actor.last_run().wait_for_finish()
184+
await (await inner_actor.last_run()).wait_for_finish()
185185

186-
inner_output_record = await inner_actor.last_run().key_value_store().get_record('OUTPUT')
186+
inner_output_record = await (await inner_actor.last_run()).key_value_store().get_record('OUTPUT')
187187
assert inner_output_record is not None
188188
assert inner_output_record['value'] == f'{test_value}_XXX_{test_value}'
189189

@@ -231,9 +231,9 @@ async def main_outer() -> None:
231231
assert outer_run_result is not None
232232
assert outer_run_result['status'] == 'SUCCEEDED'
233233

234-
await inner_actor.last_run().wait_for_finish()
234+
await (await inner_actor.last_run()).wait_for_finish()
235235

236-
inner_output_record = await inner_actor.last_run().key_value_store().get_record('OUTPUT')
236+
inner_output_record = await (await inner_actor.last_run()).key_value_store().get_record('OUTPUT')
237237
assert inner_output_record is not None
238238
assert inner_output_record['value'] == f'{test_value}_XXX_{test_value}'
239239

@@ -267,12 +267,12 @@ async def main_outer() -> None:
267267
assert outer_run_result is not None
268268
assert outer_run_result['status'] == 'SUCCEEDED'
269269

270-
await inner_actor.last_run().wait_for_finish()
271-
inner_actor_last_run = await inner_actor.last_run().get()
270+
await (await inner_actor.last_run()).wait_for_finish()
271+
inner_actor_last_run = await (await inner_actor.last_run()).get()
272272
assert inner_actor_last_run is not None
273273
assert inner_actor_last_run['status'] == 'ABORTED'
274274

275-
inner_output_record = await inner_actor.last_run().key_value_store().get_record('OUTPUT')
275+
inner_output_record = (await inner_actor.last_run()).key_value_store().get_record('OUTPUT')
276276
assert inner_output_record is None
277277

278278

@@ -320,7 +320,7 @@ async def main_outer() -> None:
320320
assert outer_run_result is not None
321321
assert outer_run_result['status'] == 'SUCCEEDED'
322322

323-
outer_run_key_value_store = outer_actor.last_run().key_value_store()
323+
outer_run_key_value_store = (await outer_actor.last_run()).key_value_store()
324324

325325
outer_output_record = await outer_run_key_value_store.get_record('OUTPUT')
326326
assert outer_output_record is not None
@@ -329,7 +329,7 @@ async def main_outer() -> None:
329329
assert await outer_run_key_value_store.get_record('RECORD_AFTER_METAMORPH_CALL') is None
330330

331331
# After metamorph, the run still belongs to the original actor, so the inner one should have no runs
332-
assert await inner_actor.last_run().get() is None
332+
assert (await inner_actor.last_run()).get() is None
333333

334334

335335
class TestActorReboot:
@@ -353,10 +353,10 @@ async def main() -> None:
353353
assert run_result is not None
354354
assert run_result['status'] == 'SUCCEEDED'
355355

356-
not_written_value = await actor.last_run().key_value_store().get_record('THIS_KEY_SHOULD_NOT_BE_WRITTEN')
356+
not_written_value = await (await actor.last_run()).key_value_store().get_record('THIS_KEY_SHOULD_NOT_BE_WRITTEN')
357357
assert not_written_value is None
358358

359-
reboot_counter = await actor.last_run().key_value_store().get_record('reboot_counter')
359+
reboot_counter = await (await actor.last_run()).key_value_store().get_record('reboot_counter')
360360
assert reboot_counter is not None
361361
assert reboot_counter['value'] == 2
362362

@@ -419,20 +419,20 @@ async def main_client() -> None:
419419
server_actor_container_url = server_actor_run['containerUrl']
420420

421421
# Give the server actor some time to start running
422-
server_actor_initialized = await server_actor.last_run().key_value_store().get_record('INITIALIZED')
422+
server_actor_initialized = await (await server_actor.last_run()).key_value_store().get_record('INITIALIZED')
423423
while not server_actor_initialized:
424-
server_actor_initialized = await server_actor.last_run().key_value_store().get_record('INITIALIZED')
424+
server_actor_initialized = await (await server_actor.last_run()).key_value_store().get_record('INITIALIZED')
425425
await asyncio.sleep(1)
426426

427427
client_actor_run_result = await client_actor.call(run_input={'server_actor_container_url': server_actor_container_url})
428428
assert client_actor_run_result is not None
429429
assert client_actor_run_result['status'] == 'SUCCEEDED'
430430

431-
server_actor_run_result = await server_actor.last_run().wait_for_finish()
431+
server_actor_run_result = await (await server_actor.last_run()).wait_for_finish()
432432
assert server_actor_run_result is not None
433433
assert server_actor_run_result['status'] == 'SUCCEEDED'
434434

435-
webhook_body_record = await server_actor.last_run().key_value_store().get_record('WEBHOOK_BODY')
435+
webhook_body_record = await (await server_actor.last_run()).key_value_store().get_record('WEBHOOK_BODY')
436436
assert webhook_body_record is not None
437437
assert webhook_body_record['value'] != ''
438438
parsed_webhook_body = json.loads(webhook_body_record['value'])

tests/integration/test_actor_dataset.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ async def main() -> None:
2929

3030
assert run_result is not None
3131
assert run_result['status'] == 'SUCCEEDED'
32-
list_page = await actor.last_run().dataset().list_items()
32+
list_page = await (await actor.last_run()).dataset().list_items()
3333
assert list_page.items[0]['id'] == 0
3434
assert list_page.items[-1]['id'] == desired_item_count - 1
3535
assert len(list_page.items) == list_page.count == desired_item_count
@@ -45,7 +45,7 @@ async def main() -> None:
4545

4646
assert run_result is not None
4747
assert run_result['status'] == 'SUCCEEDED'
48-
async for item in actor.last_run().dataset().iterate_items():
48+
async for item in (await actor.last_run()).dataset().iterate_items():
4949
assert item['str'] == 'x' * 10000
5050

5151

tests/integration/test_actor_events.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ async def log_event(data: Any) -> None:
5858

5959
assert run_result is not None
6060
assert run_result['status'] == 'SUCCEEDED'
61-
dataset_items_page = await actor.last_run().dataset().list_items()
61+
dataset_items_page = await (await actor.last_run()).dataset().list_items()
6262
persist_state_events = [item for item in dataset_items_page.items if item['event_type'] == ActorEventTypes.PERSIST_STATE]
6363
system_info_events = [item for item in dataset_items_page.items if item['event_type'] == ActorEventTypes.SYSTEM_INFO]
6464
assert len(persist_state_events) > 2

tests/integration/test_actor_key_value_store.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ async def main_set() -> None:
109109
assert run_result_set is not None
110110
assert run_result_set['status'] == 'SUCCEEDED'
111111
# Externally check if the value is present in key-value store
112-
test_record = await actor_set.last_run().key_value_store().get_record('test')
112+
test_record = await (await actor_set.last_run()).key_value_store().get_record('test')
113113
assert test_record is not None
114114
test_value = test_record['value']
115115
assert test_value['number'] == 123
@@ -127,7 +127,7 @@ async def main_get() -> None:
127127
assert value['nested']['test'] == 1
128128

129129
actor_get = await make_actor('actor-get-value', main_func=main_get)
130-
default_kvs_info = await actor_set.last_run().key_value_store().get()
130+
default_kvs_info = await (await actor_set.last_run()).key_value_store().get()
131131
assert default_kvs_info is not None
132132

133133
run_result_get = await actor_get.call(run_input={'kvs-id': default_kvs_info['id']})

tests/integration/test_actor_lifecycle.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,6 @@ async def actor_function() -> None:
147147
run_with_output = await actor.call(run_input={'set_output': test_output})
148148
assert run_with_output is not None
149149
assert run_with_output['status'] == 'SUCCEEDED'
150-
output = await actor.last_run().key_value_store().get_record('OUTPUT')
150+
output = await (await actor.last_run()).key_value_store().get_record('OUTPUT')
151151
assert output is not None
152152
assert output['value'] == test_output

tests/integration/test_actor_log.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ async def main() -> None:
5555
assert run_result is not None
5656
assert run_result['status'] == 'FAILED'
5757

58-
run_log = await actor.last_run().log().get()
58+
run_log = await (await actor.last_run()).log().get()
5959
assert run_log is not None
6060

6161
run_log_lines = run_log.splitlines()

tests/integration/test_fixtures.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ async def main() -> None:
2929
assert run_result is not None
3030
assert run_result['status'] == 'SUCCEEDED'
3131

32-
output_record = await actor.last_run().key_value_store().get_record('OUTPUT')
32+
output_record = await (await actor.last_run()).key_value_store().get_record('OUTPUT')
3333
assert output_record is not None
3434
assert run_result['actId'] == output_record['value']
3535

@@ -49,7 +49,7 @@ async def main():
4949
assert run_result is not None
5050
assert run_result['status'] == 'SUCCEEDED'
5151

52-
output_record = await actor.last_run().key_value_store().get_record('OUTPUT')
52+
output_record = await (await actor.last_run()).key_value_store().get_record('OUTPUT')
5353
assert output_record is not None
5454
assert output_record['value'] == expected_output
5555

@@ -79,7 +79,7 @@ async def main():
7979
assert actor_run is not None
8080
assert actor_run['status'] == 'SUCCEEDED'
8181

82-
output_record = await actor.last_run().key_value_store().get_record('OUTPUT')
82+
output_record = await (await actor.last_run()).key_value_store().get_record('OUTPUT')
8383
assert output_record is not None
8484

8585
output_datetime = datetime.fromisoformat(output_record['value'])

0 commit comments

Comments
 (0)