Skip to content

Commit

Permalink
The django.utils.timezone.utc alias is deprecated. Please update your…
Browse files Browse the repository at this point in the history
… code to use datetime.timezone.utc instead #1594
  • Loading branch information
dennissiemensma committed Jun 11, 2024
1 parent d8039fc commit 9d739cf
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 10 deletions.
5 changes: 3 additions & 2 deletions src/dsmr_consumption/tests/test_services.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import datetime
from decimal import Decimal
from unittest import mock

Expand Down Expand Up @@ -76,10 +77,10 @@ def test_processing(self):
[
# Asume a one hour backtrack.
timezone.make_aware(
timezone.datetime(2015, 11, 10, hour=18), timezone.utc
timezone.datetime(2015, 11, 10, hour=18), datetime.timezone.utc
),
timezone.make_aware(
timezone.datetime(2015, 11, 10, hour=19), timezone.utc
timezone.datetime(2015, 11, 10, hour=19), datetime.timezone.utc
),
],
)
Expand Down
5 changes: 3 additions & 2 deletions src/dsmr_datalogger/tests/models/test_reading.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import datetime
from unittest import mock

from django.test import TestCase
Expand All @@ -10,7 +11,7 @@ class TestDsmrReading(TestCase):
@mock.patch("django.utils.timezone.now")
def setUp(self, now_mock):
now_mock.return_value = timezone.make_aware(
timezone.datetime(2018, 1, 1), timezone=timezone.utc
timezone.datetime(2018, 1, 1), timezone=datetime.timezone.utc
)
self.instance = DsmrReading.objects.create(
timestamp=timezone.now(),
Expand Down Expand Up @@ -39,7 +40,7 @@ def test_managers(self):
def test_convert_to_local_timezone(self, now_mock):
"""Test altering the timezone formatting for the timestamps."""
now_mock.return_value = timezone.make_aware(
timezone.datetime(2018, 1, 1), timezone=timezone.utc
timezone.datetime(2018, 1, 1), timezone=datetime.timezone.utc
)

self.assertEqual(str(self.instance.timestamp), "2018-01-01 00:00:00+00:00")
Expand Down
9 changes: 5 additions & 4 deletions src/dsmr_mqtt/tests/services/test_consumption.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import datetime
from unittest import mock
import json

Expand Down Expand Up @@ -89,7 +90,7 @@ def test_create_electricity_signal(self, *service_mocks):
@mock.patch("django.utils.timezone.now")
def test_publish_json_gas_consumption(self, now_mock, queue_message_mock):
now_mock.return_value = timezone.make_aware(
timezone.datetime(2020, 1, 1), timezone=timezone.utc
timezone.datetime(2020, 1, 1), timezone=datetime.timezone.utc
)
json_settings = consumption.JSONGasConsumptionMQTTSettings.get_solo()
gas_consumption = self._create_gas_consumption()
Expand Down Expand Up @@ -130,7 +131,7 @@ def test_publish_json_gas_consumption(self, now_mock, queue_message_mock):
@mock.patch("django.utils.timezone.now")
def test_publish_split_topic_gas_consumption(self, now_mock, queue_message_mock):
now_mock.return_value = timezone.make_aware(
timezone.datetime(2020, 1, 1), timezone=timezone.utc
timezone.datetime(2020, 1, 1), timezone=datetime.timezone.utc
)
split_topic_settings = (
consumption.SplitTopicGasConsumptionMQTTSettings.get_solo()
Expand Down Expand Up @@ -176,7 +177,7 @@ def test_publish_json_quarter_hour_peak_consumption(
self, now_mock, queue_message_mock
):
now_mock.return_value = timezone.make_aware(
timezone.datetime(2023, 1, 1), timezone=timezone.utc
timezone.datetime(2023, 1, 1), timezone=datetime.timezone.utc
)
json_settings = (
consumption.JSONQuarterHourPeakElectricityConsumptionMQTTSettings.get_solo()
Expand Down Expand Up @@ -221,7 +222,7 @@ def test_publish_split_topic_quarter_hour_peak_consumption(
self, now_mock, queue_message_mock
):
now_mock.return_value = timezone.make_aware(
timezone.datetime(2023, 1, 1), timezone=timezone.utc
timezone.datetime(2023, 1, 1), timezone=datetime.timezone.utc
)
split_topic_settings = (
consumption.SplitTopicQuarterHourPeakElectricityConsumptionMQTTSettings.get_solo()
Expand Down
5 changes: 3 additions & 2 deletions src/dsmr_mqtt/tests/services/test_telegram.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import datetime
from unittest import mock
import json

Expand Down Expand Up @@ -86,7 +87,7 @@ def test_publish_raw_dsmr_telegram(self, queue_message_mock):
@mock.patch("django.utils.timezone.now")
def test_publish_json_dsmr_reading(self, now_mock, queue_message_mock):
now_mock.return_value = timezone.make_aware(
timezone.datetime(2018, 1, 1), timezone=timezone.utc
timezone.datetime(2018, 1, 1), timezone=datetime.timezone.utc
)
json_settings = telegram.JSONTelegramMQTTSettings.get_solo()
dsmr_reading = self._create_dsmrreading()
Expand Down Expand Up @@ -161,7 +162,7 @@ def test_publish_json_dsmr_reading(self, now_mock, queue_message_mock):
@mock.patch("django.utils.timezone.now")
def test_publish_split_topic_dsmr_reading(self, now_mock, queue_message_mock):
now_mock.return_value = timezone.make_aware(
timezone.datetime(2018, 1, 1), timezone=timezone.utc
timezone.datetime(2018, 1, 1), timezone=datetime.timezone.utc
)
split_topic_settings = telegram.SplitTopicTelegramMQTTSettings.get_solo()
dsmr_reading = self._create_dsmrreading()
Expand Down

0 comments on commit 9d739cf

Please sign in to comment.