-
-
Notifications
You must be signed in to change notification settings - Fork 47
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #151 from npt/master
Fix another DeprecationWarning, and a bug in _is_expired
- Loading branch information
Showing
2 changed files
with
24 additions
and
2 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,19 @@ | ||
import datetime | ||
|
||
from aiogoogle.auth.utils import _get_expires_at, _is_expired | ||
|
||
|
||
def test_get_expires_at(): | ||
exp_str = _get_expires_at(120) | ||
exp_dt = datetime.datetime.fromisoformat(exp_str) | ||
assert exp_dt.tzinfo is None | ||
delta = datetime.datetime.now(datetime.timezone.utc).replace(tzinfo=None) - exp_dt | ||
assert -1 < delta.seconds < 1 | ||
|
||
|
||
def test_is_expired(): | ||
# correctness not tested, but none of these should raise an exception | ||
_is_expired("2024-10-01T14:26:21") | ||
_is_expired("2024-10-01T14:26:21+00:00") | ||
_is_expired(datetime.datetime.now()) | ||
_is_expired(datetime.datetime.now(datetime.timezone.utc)) |