Skip to content

Commit 605c182

Browse files
committed
Fixes
1 parent 154c874 commit 605c182

File tree

2 files changed

+31
-26
lines changed

2 files changed

+31
-26
lines changed

src/apify/_charging.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -356,7 +356,8 @@ async def _fetch_pricing_info(self) -> _FetchedPricingInfoDict:
356356
if run is None:
357357
raise RuntimeError('Actor run not found')
358358

359-
actor_run = run_validator.validate_python(run)
359+
run_dict = run.model_dump(by_alias=True)
360+
actor_run = run_validator.validate_python(run_dict)
360361

361362
if actor_run is None:
362363
raise RuntimeError('Actor run not found')

tests/unit/actor/test_actor_lifecycle.py

Lines changed: 29 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
import pytest
1313
import websockets.asyncio.server
1414

15+
from apify_client._models import Run
1516
from apify_shared.consts import ActorEnvVars, ActorExitCodes, ApifyEnvVars
1617
from crawlee.events._types import Event, EventPersistStateData
1718

@@ -238,31 +239,34 @@ async def handler(websocket: websockets.asyncio.server.ServerConnection) -> None
238239

239240
mock_run_client = Mock()
240241
mock_run_client.run.return_value.get = AsyncMock(
241-
side_effect=lambda: {
242-
'id': 'asdf',
243-
'actId': 'asdf',
244-
'userId': 'adsf',
245-
'startedAt': datetime.now(timezone.utc),
246-
'status': 'RUNNING',
247-
'meta': {'origin': 'DEVELOPMENT'},
248-
'stats': {
249-
'inputBodyLen': 99,
250-
'restartCount': 0,
251-
'resurrectCount': 0,
252-
'computeUnits': 1,
253-
},
254-
'options': {
255-
'build': 'asdf',
256-
'timeoutSecs': 4,
257-
'memoryMbytes': 1024,
258-
'diskMbytes': 1024,
259-
},
260-
'buildId': 'hjkl',
261-
'defaultDatasetId': 'hjkl',
262-
'defaultKeyValueStoreId': 'hjkl',
263-
'defaultRequestQueueId': 'hjkl',
264-
'containerUrl': 'https://hjkl',
265-
}
242+
side_effect=lambda: Run.model_validate(
243+
{
244+
'id': 'asdf',
245+
'actId': 'asdf',
246+
'userId': 'adsf',
247+
'startedAt': datetime.now(timezone.utc).isoformat(),
248+
'status': 'RUNNING',
249+
'meta': {'origin': 'DEVELOPMENT'},
250+
'stats': {
251+
'restartCount': 0,
252+
'resurrectCount': 0,
253+
'computeUnits': 1,
254+
},
255+
'options': {
256+
'build': 'asdf',
257+
'timeoutSecs': 4,
258+
'memoryMbytes': 1024,
259+
'diskMbytes': 1024,
260+
},
261+
'buildId': 'hjkl',
262+
'defaultDatasetId': 'hjkl',
263+
'defaultKeyValueStoreId': 'hjkl',
264+
'defaultRequestQueueId': 'hjkl',
265+
'containerUrl': 'https://hjkl',
266+
'buildNumber': '0.0.1',
267+
'generalAccess': 'RESTRICTED',
268+
}
269+
)
266270
)
267271

268272
with mock.patch.object(Actor, 'new_client', return_value=mock_run_client):

0 commit comments

Comments
 (0)