Skip to content

Commit

Permalink
tests: use time-machine instead of freezegun
Browse files Browse the repository at this point in the history
  • Loading branch information
azmeuk committed May 2, 2024
1 parent e89a0d6 commit a6b32e4
Show file tree
Hide file tree
Showing 3 changed files with 73 additions and 19 deletions.
84 changes: 69 additions & 15 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ optional = true
coverage = "^7.2.2"
flake8 = "^7.0.0"
Flask-WebTest = "^0.1.3"
freezegun = "^1.2.2"
pre-commit = "^3.1.1"
pytest = "^8.0.0"
pytest-cov = "^5.0.0"
Expand All @@ -51,6 +50,7 @@ pytest-mock = "^3.11.1"
wsgidav = "^4.3.1"
pytest-smtpd = "^0.1.0"
pyquery = "^2.0.0"
time-machine = "^2.14.1"

[tool.poetry.group.doc]
optional = true
Expand Down
6 changes: 3 additions & 3 deletions web/tests/test_user.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import pytest
import requests
from freezegun import freeze_time
from time_machine import travel

from b3desk.models import db
from b3desk.models.users import NoUserFound
Expand Down Expand Up @@ -36,10 +36,10 @@ def test_update_last_connection_if_more_than_24h(client_app):
"preferred_username": "alice",
"email": "[email protected]",
}
with freeze_time("2021-08-10"):
with travel("2021-08-10 12:00:00"):
get_or_create_user(user_info)

with freeze_time("2021-08-11"):
with travel("2021-08-11 12:00:00"):
user = db.session.get(User, 1)
assert user.last_connection_utc_datetime.date() == date(2021, 8, 10)

Expand Down

0 comments on commit a6b32e4

Please sign in to comment.