Skip to content

Commit f1d5a06

Browse files
authored
test: Add the required unique_key when building a Request without an ID (#1032)
Master CI is red on every type-check and unit-test job: https://github.com/apify/apify-client-python/actions/runs/32821686073 Two PRs that each passed CI on their own conflict semantically once merged together: - #1030 made `unique_key` a required field on `RequestBase`. - #1025 added two tests that build `Request(url='https://example.com')` to assert `update_request` rejects a request with no ID. In that order, the `Request` constructor now raises a pydantic `ValidationError` for the missing `uniqueKey` before `update_request` is ever reached — so `ty` reported 2 `missing-argument` diagnostics and both tests failed on the wrong exception. Supplying the now-required `unique_key` makes the tests exercise what they were written for (the missing ID), not model validation. *✍️ Drafted by Claude Code*
1 parent 3e333a0 commit f1d5a06

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

‎tests/unit/test_url_path_encoding.py‎

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -419,12 +419,16 @@ def test_update_request_without_an_id_is_rejected_sync(*, api_url: str) -> None:
419419
client = ApifyClient(token='test_token', api_url=api_url)
420420

421421
with pytest.raises(ValueError, match='must have an ID'):
422-
client.request_queue(_QUEUE_ID).update_request(Request(url='https://example.com'))
422+
client.request_queue(_QUEUE_ID).update_request(
423+
Request(url='https://example.com', unique_key='https://example.com')
424+
)
423425

424426

425427
async def test_update_request_without_an_id_is_rejected_async(*, api_url: str) -> None:
426428
"""A request carrying no ID cannot address a queue record, so the update is refused before it is sent."""
427429
client = ApifyClientAsync(token='test_token', api_url=api_url)
428430

429431
with pytest.raises(ValueError, match='must have an ID'):
430-
await client.request_queue(_QUEUE_ID).update_request(Request(url='https://example.com'))
432+
await client.request_queue(_QUEUE_ID).update_request(
433+
Request(url='https://example.com', unique_key='https://example.com')
434+
)

0 commit comments

Comments
 (0)