-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(tasks): resolve incorrect UTC timezone usage for task completion …
…dates in list view (#1786)
- Loading branch information
1 parent
20a49c7
commit 1f23998
Showing
4 changed files
with
38 additions
and
5 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
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,29 @@ | ||
import datetime | ||
|
||
from sqlalchemy.orm import Session # type: ignore | ||
|
||
from antarest.core.tasks.model import TaskJob | ||
|
||
|
||
def test_database_date_utc(db_session: Session) -> None: | ||
now = datetime.datetime.utcnow() | ||
later = now + datetime.timedelta(seconds=1) | ||
|
||
with db_session: | ||
task_job = TaskJob(name="foo") | ||
db_session.add(task_job) | ||
db_session.commit() | ||
|
||
with db_session: | ||
task_job = db_session.query(TaskJob).filter(TaskJob.name == "foo").one() | ||
assert now <= task_job.creation_date <= later | ||
assert task_job.completion_date is None | ||
|
||
with db_session: | ||
task_job = db_session.query(TaskJob).filter(TaskJob.name == "foo").one() | ||
task_job.completion_date = datetime.datetime.utcnow() | ||
db_session.commit() | ||
|
||
with db_session: | ||
task_job = db_session.query(TaskJob).filter(TaskJob.name == "foo").one() | ||
assert now <= task_job.creation_date <= task_job.completion_date <= later |