-
Notifications
You must be signed in to change notification settings - Fork 427
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This is gonna be useful for monitoring and debugging when jobs appear in log messages and tracebacks, Sentry issues, etc.
- Loading branch information
Showing
2 changed files
with
60 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
from datetime import datetime | ||
|
||
from h.models.job import Job | ||
|
||
|
||
class TestJob: | ||
def test___repr__(self): | ||
job = Job( | ||
id=42, | ||
name="job_name", | ||
enqueued_at=datetime( | ||
year=2024, | ||
month=5, | ||
day=8, | ||
hour=11, | ||
minute=51, | ||
second=23, | ||
), | ||
scheduled_at=datetime( | ||
year=2024, | ||
month=6, | ||
day=1, | ||
hour=0, | ||
minute=0, | ||
second=0, | ||
), | ||
expires_at=datetime( | ||
year=2025, | ||
month=1, | ||
day=1, | ||
hour=0, | ||
minute=0, | ||
second=0, | ||
), | ||
priority=3, | ||
tag="job_tag", | ||
kwargs={"foo": "FOO", "bar": "BAR"}, | ||
) | ||
|
||
assert ( | ||
repr(job) | ||
== "Job(id=42, name='job_name', enqueued_at=datetime.datetime(2024, 5, 8, 11, 51, 23), scheduled_at=datetime.datetime(2024, 6, 1, 0, 0), expires_at=datetime.datetime(2025, 1, 1, 0, 0), priority=3, tag='job_tag', kwargs={'foo': 'FOO', 'bar': 'BAR'})" | ||
) |