Skip to content

Commit 8969cbf

Browse files
authored
Add created field to jobs (#49)
1 parent 7e92f6f commit 8969cbf

File tree

4 files changed

+14
-0
lines changed

4 files changed

+14
-0
lines changed

aiohasupervisor/models/jobs.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
from __future__ import annotations
44

55
from dataclasses import dataclass
6+
from datetime import datetime # noqa: TCH003
67
from enum import StrEnum
78
from uuid import UUID # noqa: TCH003
89

@@ -57,6 +58,7 @@ class Job(ResponseData):
5758
stage: str | None
5859
done: bool | None
5960
errors: list[JobError]
61+
created: datetime
6062
child_jobs: list[Job]
6163

6264

tests/fixtures/jobs_get_job.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
"stage": "finishing_file",
99
"done": true,
1010
"errors": [],
11+
"created": "2025-01-30T20:55:12.859349+00:00",
1112
"child_jobs": [
1213
{
1314
"name": "backup_store_folders",
@@ -17,6 +18,7 @@
1718
"stage": null,
1819
"done": true,
1920
"errors": [],
21+
"created": "2025-01-30T20:55:12.892008+00:00",
2022
"child_jobs": [
2123
{
2224
"name": "backup_folder_save",
@@ -26,6 +28,7 @@
2628
"stage": null,
2729
"done": true,
2830
"errors": [],
31+
"created": "2025-01-30T20:55:12.892699+00:00",
2932
"child_jobs": []
3033
}
3134
]

tests/fixtures/jobs_info.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
"stage": "finishing_file",
1212
"done": true,
1313
"errors": [],
14+
"created": "2025-01-30T20:55:12.859349+00:00",
1415
"child_jobs": [
1516
{
1617
"name": "backup_store_folders",
@@ -20,6 +21,7 @@
2021
"stage": null,
2122
"done": true,
2223
"errors": [],
24+
"created": "2025-01-30T20:55:12.892008+00:00",
2325
"child_jobs": [
2426
{
2527
"name": "backup_folder_save",
@@ -29,6 +31,7 @@
2931
"stage": null,
3032
"done": true,
3133
"errors": [],
34+
"created": "2025-01-30T20:55:12.892699+00:00",
3235
"child_jobs": []
3336
}
3437
]
@@ -48,6 +51,7 @@
4851
"message": "Invalid password for backup cfddca18"
4952
}
5053
],
54+
"created": "2025-01-30T20:55:15.000000+00:00",
5155
"child_jobs": []
5256
}
5357
]

tests/test_jobs.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
"""Test jobs supervisor client."""
22

3+
from datetime import datetime
34
from uuid import UUID
45

56
from aioresponses import aioresponses
@@ -29,6 +30,9 @@ async def test_jobs_info(
2930
assert info.jobs[0].stage == "finishing_file"
3031
assert info.jobs[0].done is True
3132
assert info.jobs[0].errors == []
33+
assert info.jobs[0].created == datetime.fromisoformat(
34+
"2025-01-30T20:55:12.859349+00:00"
35+
)
3236
assert info.jobs[0].child_jobs[0].name == "backup_store_folders"
3337
assert info.jobs[0].child_jobs[0].child_jobs[0].name == "backup_folder_save"
3438
assert info.jobs[0].child_jobs[0].child_jobs[0].reference == "ssl"
@@ -85,6 +89,7 @@ async def test_jobs_get_job(
8589
assert info.stage == "finishing_file"
8690
assert info.done is True
8791
assert info.errors == []
92+
assert info.created == datetime.fromisoformat("2025-01-30T20:55:12.859349+00:00")
8893
assert info.child_jobs[0].name == "backup_store_folders"
8994
assert info.child_jobs[0].child_jobs[0].name == "backup_folder_save"
9095
assert info.child_jobs[0].child_jobs[0].reference == "ssl"

0 commit comments

Comments
 (0)