Skip to content

Commit

Permalink
fix: django 5 deprecation warning by using datetime.timezone.utc
Browse files Browse the repository at this point in the history
RemovedInDjango50Warning:
 - The django.utils.timezone.utc alias is deprecated.
   Please update your code to use datetime.timezone.utc instead.

refs YJDH-696
  • Loading branch information
karisal-anders committed Jul 22, 2024
1 parent 6547de6 commit 54c1aa8
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 17 deletions.
8 changes: 4 additions & 4 deletions backend/shared/shared/audit_log/tests/test_audit_logging.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
from datetime import datetime, timedelta
from datetime import datetime, timedelta, timezone
from unittest import mock

import pytest
from django.contrib.auth.models import AnonymousUser
from django.test import override_settings
from django.utils import timezone
from django.utils.timezone import now

from shared.audit_log import audit_logging
from shared.audit_log.enums import Operation, Status
Expand Down Expand Up @@ -388,11 +388,11 @@ def test_clear_audit_log(user, fixed_datetime):
new_sent_log.is_sent = True
new_sent_log.save()

expired_unsent_log.created_at = timezone.now() - timedelta(days=35)
expired_unsent_log.created_at = now() - timedelta(days=35)
expired_unsent_log.save()

expired_sent_log.is_sent = True
expired_sent_log.created_at = timezone.now() - timedelta(days=35)
expired_sent_log.created_at = now() - timedelta(days=35)
expired_sent_log.save()

deleted_count = clear_audit_log_entries()
Expand Down
19 changes: 6 additions & 13 deletions backend/shared/shared/common/tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import pytest
from django.test import Client
from django.utils import timezone
from django.utils.timezone import now

from shared.common.tests.factories import (
StaffSuperuserFactory,
Expand All @@ -14,26 +14,19 @@

def store_tokens_in_session(client):
s = client.session
now_plus_1_hour = now() + timedelta(hours=1)
s.update(
{
"oidc_id_token": "test",
"oidc_access_token": "test",
"oidc_refresh_token": "test",
"oidc_access_token_expires": (
timezone.now() + timedelta(hours=1)
).isoformat(),
"oidc_refresh_token_expires": (
timezone.now() + timedelta(hours=1)
).isoformat(),
"oidc_access_token_expires": now_plus_1_hour.isoformat(),
"oidc_refresh_token_expires": now_plus_1_hour.isoformat(),
"eauth_id_token": "test",
"eauth_access_token": "test",
"eauth_refresh_token": "test",
"eauth_access_token_expires": (
timezone.now() + timedelta(hours=1)
).isoformat(),
"eauth_refresh_token_expires": (
timezone.now() + timedelta(hours=1)
).isoformat(),
"eauth_access_token_expires": now_plus_1_hour.isoformat(),
"eauth_refresh_token_expires": now_plus_1_hour.isoformat(),
}
)
s.save()
Expand Down

0 comments on commit 54c1aa8

Please sign in to comment.