Skip to content

Commit

Permalink
Add -1 case
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrew Yoo committed Jul 6, 2023
1 parent b0749b2 commit e73f397
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions t/unit/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,25 @@ def test_make_aware_not_use_tz_naive_not_dst(self, mock_getattr, mock_is_naive,
@mock.patch('django_celery_beat.utils.time.localtime')
@mock.patch('django_celery_beat.utils.timezone.is_naive')
@mock.patch('django_celery_beat.utils.getattr')
def test_make_aware_not_use_tz_naive_negative_dst(self, mock_getattr, mock_is_naive, mock_localtime_1, mock_make_aware, mock_get_default_timezone, mock_localtime_2):
dt = datetime(2022, 11, 6, 1, 15, 0)
mock_getattr.return_value = False
mock_is_naive.return_value = True
mock_get_default_timezone.return_value = "America/Los_Angeles"
mock_localtime_1.return_value = time.struct_time([2022, 11, 6, 1, 15, 0, 0, 310, -1])
mock_make_aware.return_value = dt

self.assertEquals(utils.make_aware(dt), dt)

mock_localtime_1.assert_called_with()
mock_make_aware.assert_called_with(dt, "America/Los_Angeles", is_dst=None)
mock_get_default_timezone.assert_called()
@mock.patch('django_celery_beat.utils.timezone.localtime')
@mock.patch('django_celery_beat.utils.timezone.get_default_timezone')
@mock.patch('django_celery_beat.utils.timezone.make_aware')
@mock.patch('django_celery_beat.utils.time.localtime')
@mock.patch('django_celery_beat.utils.timezone.is_naive')
@mock.patch('django_celery_beat.utils.getattr')
def test_make_aware_not_use_tz_not_naive_dst(self, mock_getattr, mock_is_naive, mock_localtime_1, mock_make_aware, mock_get_default_timezone, mock_localtime_2):
dt = datetime(2022, 11, 6, 1, 15, 0)
mock_getattr.return_value = False
Expand Down

0 comments on commit e73f397

Please sign in to comment.