|
12 | 12 | import pytest |
13 | 13 | import websockets.asyncio.server |
14 | 14 |
|
| 15 | +from apify_client._models import Run |
15 | 16 | from apify_shared.consts import ActorEnvVars, ActorExitCodes, ApifyEnvVars |
16 | 17 | from crawlee.events._types import Event, EventPersistStateData |
17 | 18 |
|
@@ -238,31 +239,34 @@ async def handler(websocket: websockets.asyncio.server.ServerConnection) -> None |
238 | 239 |
|
239 | 240 | mock_run_client = Mock() |
240 | 241 | 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 | + ) |
266 | 270 | ) |
267 | 271 |
|
268 | 272 | with mock.patch.object(Actor, 'new_client', return_value=mock_run_client): |
|
0 commit comments