Skip to content

Commit

Permalink
v9.4.0
Browse files Browse the repository at this point in the history
  • Loading branch information
GitRon committed Dec 5, 2023
1 parent 9b00980 commit 458e65b
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions tests/test_models.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import datetime
from unittest.mock import PropertyMock, patch

from django.test import TestCase
Expand Down Expand Up @@ -36,7 +35,10 @@ def test_save_update_fields_common_fields_set(self):
obj.refresh_from_db()
self.assertEqual(obj.value, 2)
self.assertEqual(obj.value_b, 1, "value_b should not have changed")
self.assertEqual(obj.lastmodified_at, datetime.datetime(2022, 6, 26, 10))
self.assertEqual(obj.lastmodified_at.year, 2022)
self.assertEqual(obj.lastmodified_at.month, 6)
self.assertEqual(obj.lastmodified_at.day, 26)
self.assertEqual(obj.lastmodified_at.hour, 10)

@patch("testapp.models.CommonInfoBasedModel.ALWAYS_UPDATE_FIELDS", new_callable=PropertyMock)
@freeze_time("2022-06-26 10:00")
Expand All @@ -49,7 +51,10 @@ def test_save_update_fields_common_fields_set_without_always_update(self, always

obj.refresh_from_db()
self.assertEqual(obj.value, 2)
self.assertEqual(obj.lastmodified_at, datetime.datetime(2020, 9, 19))
self.assertEqual(obj.lastmodified_at.year, 2020)
self.assertEqual(obj.lastmodified_at.month, 9)
self.assertEqual(obj.lastmodified_at.day, 19)
self.assertEqual(obj.lastmodified_at.hour, 0)

@freeze_time("2022-06-26 10:00")
def test_save_common_fields_set_without_update_fields(self):
Expand All @@ -60,4 +65,7 @@ def test_save_common_fields_set_without_update_fields(self):

obj.refresh_from_db()
self.assertEqual(obj.value, 2)
self.assertEqual(obj.lastmodified_at, datetime.datetime(2022, 6, 26, 10))
self.assertEqual(obj.lastmodified_at.year, 2022)
self.assertEqual(obj.lastmodified_at.month, 6)
self.assertEqual(obj.lastmodified_at.day, 26)
self.assertEqual(obj.lastmodified_at.hour, 10)

0 comments on commit 458e65b

Please sign in to comment.