Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add created field to jobs #49

Merged
merged 1 commit into from
Jan 31, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions aiohasupervisor/models/jobs.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from __future__ import annotations

from dataclasses import dataclass
from datetime import datetime # noqa: TCH003
from enum import StrEnum
from uuid import UUID # noqa: TCH003

Expand Down Expand Up @@ -57,6 +58,7 @@ class Job(ResponseData):
stage: str | None
done: bool | None
errors: list[JobError]
created: datetime
child_jobs: list[Job]


Expand Down
3 changes: 3 additions & 0 deletions tests/fixtures/jobs_get_job.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"stage": "finishing_file",
"done": true,
"errors": [],
"created": "2025-01-30T20:55:12.859349+00:00",
"child_jobs": [
{
"name": "backup_store_folders",
Expand All @@ -17,6 +18,7 @@
"stage": null,
"done": true,
"errors": [],
"created": "2025-01-30T20:55:12.892008+00:00",
"child_jobs": [
{
"name": "backup_folder_save",
Expand All @@ -26,6 +28,7 @@
"stage": null,
"done": true,
"errors": [],
"created": "2025-01-30T20:55:12.892699+00:00",
"child_jobs": []
}
]
Expand Down
4 changes: 4 additions & 0 deletions tests/fixtures/jobs_info.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
"stage": "finishing_file",
"done": true,
"errors": [],
"created": "2025-01-30T20:55:12.859349+00:00",
"child_jobs": [
{
"name": "backup_store_folders",
Expand All @@ -20,6 +21,7 @@
"stage": null,
"done": true,
"errors": [],
"created": "2025-01-30T20:55:12.892008+00:00",
"child_jobs": [
{
"name": "backup_folder_save",
Expand All @@ -29,6 +31,7 @@
"stage": null,
"done": true,
"errors": [],
"created": "2025-01-30T20:55:12.892699+00:00",
"child_jobs": []
}
]
Expand All @@ -48,6 +51,7 @@
"message": "Invalid password for backup cfddca18"
}
],
"created": "2025-01-30T20:55:15.000000+00:00",
"child_jobs": []
}
]
Expand Down
5 changes: 5 additions & 0 deletions tests/test_jobs.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
"""Test jobs supervisor client."""

from datetime import datetime
from uuid import UUID

from aioresponses import aioresponses
Expand Down Expand Up @@ -29,6 +30,9 @@ async def test_jobs_info(
assert info.jobs[0].stage == "finishing_file"
assert info.jobs[0].done is True
assert info.jobs[0].errors == []
assert info.jobs[0].created == datetime.fromisoformat(
"2025-01-30T20:55:12.859349+00:00"
)
assert info.jobs[0].child_jobs[0].name == "backup_store_folders"
assert info.jobs[0].child_jobs[0].child_jobs[0].name == "backup_folder_save"
assert info.jobs[0].child_jobs[0].child_jobs[0].reference == "ssl"
Expand Down Expand Up @@ -85,6 +89,7 @@ async def test_jobs_get_job(
assert info.stage == "finishing_file"
assert info.done is True
assert info.errors == []
assert info.created == datetime.fromisoformat("2025-01-30T20:55:12.859349+00:00")
assert info.child_jobs[0].name == "backup_store_folders"
assert info.child_jobs[0].child_jobs[0].name == "backup_folder_save"
assert info.child_jobs[0].child_jobs[0].reference == "ssl"
Expand Down
Loading