Skip to content

Commit 5862f42

Browse files
vdusekclaude
andcommitted
fix: update e2e tests for apify-client v3 model validation
The v3 client now validates pricing_infos dicts through pydantic models before sending to the API. Add required CommonActorPricingInfo fields (apifyMarginPercentage, createdAt, startedAt) to all pricing info dicts in test fixtures and cleanup code. Also fix UTC import missing inside serialized Actor main functions for timeout tests. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 05a8aba commit 5862f42

3 files changed

Lines changed: 17 additions & 4 deletions

File tree

tests/e2e/conftest.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -351,7 +351,15 @@ async def _make_actor(
351351
if actor is not None and actor.pricing_infos is not None:
352352
# Convert Pydantic models to dicts before mixing with plain dict
353353
existing_pricing_infos = [pi.model_dump(by_alias=True, exclude_none=True) for pi in actor.pricing_infos]
354-
new_pricing_infos = [*existing_pricing_infos, {'pricingModel': 'FREE'}]
354+
new_pricing_infos = [
355+
*existing_pricing_infos,
356+
{
357+
'pricingModel': 'FREE',
358+
'apifyMarginPercentage': 0.0,
359+
'createdAt': '2024-01-01T00:00:00.000Z',
360+
'startedAt': '2024-01-01T00:00:00.000Z',
361+
},
362+
]
355363
actor_client.update(pricing_infos=new_pricing_infos)
356364

357365
actor_client.delete()

tests/e2e/test_actor_call_timeouts.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
from __future__ import annotations
22

33
import asyncio
4-
from datetime import UTC
54
from typing import TYPE_CHECKING
65

76
from apify import Actor
@@ -20,7 +19,7 @@ async def test_actor_start_inherit_timeout(
2019
Timeout should be the remaining time of the first Actor run calculated at the moment of the other Actor start."""
2120

2221
async def main() -> None:
23-
from datetime import datetime, timedelta
22+
from datetime import UTC, datetime, timedelta
2423

2524
async with Actor:
2625
actor_input = (await Actor.get_input()) or {}
@@ -70,7 +69,7 @@ async def test_actor_call_inherit_timeout(
7069
Timeout should be the remaining time of the first Actor run calculated at the moment of the other Actor call."""
7170

7271
async def main() -> None:
73-
from datetime import datetime, timedelta
72+
from datetime import UTC, datetime, timedelta
7473

7574
async with Actor:
7675
actor_input = (await Actor.get_input()) or {}

tests/e2e/test_actor_charge.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,9 @@ async def main() -> None:
3434
pricing_infos=[
3535
{
3636
'pricingModel': 'PAY_PER_EVENT',
37+
'apifyMarginPercentage': 0.0,
38+
'createdAt': '2024-01-01T00:00:00.000Z',
39+
'startedAt': '2024-01-01T00:00:00.000Z',
3740
'pricingPerEvent': {
3841
'actorChargeEvents': {
3942
'push-item': {
@@ -84,6 +87,9 @@ async def main() -> None:
8487
pricing_infos=[
8588
{
8689
'pricingModel': 'PAY_PER_EVENT',
90+
'apifyMarginPercentage': 0.0,
91+
'createdAt': '2024-01-01T00:00:00.000Z',
92+
'startedAt': '2024-01-01T00:00:00.000Z',
8793
'pricingPerEvent': {
8894
'actorChargeEvents': {
8995
'foobar': {

0 commit comments

Comments
 (0)