Skip to content

Commit e58639b

Browse files
committed
Remove test
this tested for string timezones, which were not possible
1 parent d88ba8b commit e58639b

File tree

1 file changed

+9
-29
lines changed

1 file changed

+9
-29
lines changed

t/unit/test_schedulers.py

Lines changed: 9 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
11
import math
22
import os
33
import time
4+
<<<<<<< HEAD
45
from datetime import datetime, timedelta
56
from datetime import timezone as dt_timezone
7+
=======
8+
from datetime import UTC, datetime, timedelta
9+
>>>>>>> 1152091 (Remove test)
610
from itertools import count
711
from time import monotonic
812
from unittest.mock import patch
@@ -333,7 +337,7 @@ def test_entry_is_due__no_use_tz(self):
333337
assert self.app.timezone.key == 'Europe/Berlin'
334338

335339
# simulate last_run_at from DB - not TZ aware but localtime
336-
right_now = datetime.utcnow()
340+
right_now = datetime.now(UTC)
337341

338342
m = self.create_model_crontab(
339343
crontab(minute='*/10'),
@@ -364,7 +368,7 @@ def test_entry_and_model_last_run_at_with_utc_no_use_tz(self, monkeypatch):
364368
time.tzset()
365369
assert self.app.timezone.key == 'Europe/Berlin'
366370
# simulate last_run_at from DB - not TZ aware but localtime
367-
right_now = datetime.utcnow()
371+
right_now = datetime.now(UTC)
368372
# make sure to use fixed date time
369373
monkeypatch.setattr(self.Entry, '_default_now', lambda o: right_now)
370374
m = self.create_model_crontab(
@@ -398,7 +402,7 @@ def test_entry_and_model_last_run_at_when_model_changed(self, monkeypatch):
398402
time.tzset()
399403
assert self.app.timezone.key == 'Europe/Berlin'
400404
# simulate last_run_at from DB - not TZ aware but localtime
401-
right_now = datetime.utcnow()
405+
right_now = datetime.now(UTC)
402406
# make sure to use fixed date time
403407
monkeypatch.setattr(self.Entry, '_default_now', lambda o: right_now)
404408
m = self.create_model_crontab(
@@ -451,7 +455,7 @@ def test_entry_is_due__celery_timezone_doesnt_match_time_zone(self):
451455

452456
# simulate last_run_at all none, doing the same thing that
453457
# _default_now() would do
454-
right_now = datetime.utcnow()
458+
right_now = datetime.now(UTC)
455459

456460
m = self.create_model_crontab(
457461
crontab(minute='*/10'),
@@ -1678,31 +1682,6 @@ def setup_method(self):
16781682
def teardown_method(self):
16791683
patch.stopall()
16801684

1681-
@patch("django_celery_beat.schedulers.aware_now")
1682-
def test_server_timezone_handling_with_zoneinfo(self, mock_aware_now):
1683-
"""Test handling when server timezone
1684-
is already a ZoneInfo instance."""
1685-
1686-
# Create a mock scheduler with only the methods we need to test
1687-
class MockScheduler:
1688-
_get_timezone_offset = (
1689-
schedulers.DatabaseScheduler._get_timezone_offset
1690-
)
1691-
1692-
s = MockScheduler()
1693-
1694-
tokyo_tz = ZoneInfo("Asia/Tokyo")
1695-
mock_now = datetime(2023, 1, 1, 12, 0, 0, tzinfo=tokyo_tz)
1696-
mock_aware_now.return_value = mock_now
1697-
1698-
# Test with a different timezone
1699-
new_york_tz = "America/New_York"
1700-
offset = s._get_timezone_offset(new_york_tz) # Pass self explicitly
1701-
1702-
# Tokyo is UTC+9, New York is UTC-5, so difference should be 14 hours
1703-
assert offset == 14
1704-
assert mock_aware_now.called
1705-
17061685
@patch("django_celery_beat.schedulers.aware_now")
17071686
def test_timezone_offset_with_zoneinfo_object_param(self, mock_aware_now):
17081687
"""Test handling when timezone_name parameter is a ZoneInfo object."""
@@ -1724,3 +1703,4 @@ class MockScheduler:
17241703

17251704
# Tokyo is UTC+9, New York is UTC-5, so difference should be 14 hours
17261705
assert offset == 14
1706+
assert mock_aware_now.called

0 commit comments

Comments
 (0)