mirror of
https://github.com/jazzband/django-auditlog.git
synced 2026-05-01 12:14:49 +00:00
Ensure db affinity between model and LogEntry
This test case would fail occasionally--sometimes accessing `history` would try pulling from "default" instead of the "postgres" database. To fix this issue generally, this change: https://github.com/jjkester/django-auditlog/pull/94/files#diff-10976dd6652a7dba50d5de998672e49bR60 should be propagated somehow into `AuditlogHistoryField`.
This commit is contained in:
parent
e0e6acb49c
commit
8b84777117
1 changed files with 8 additions and 4 deletions
|
|
@ -582,20 +582,24 @@ class PostgresArrayFieldModelTest(TestCase):
|
|||
arrayfield=[PostgresArrayFieldModel.RED, PostgresArrayFieldModel.GREEN],
|
||||
)
|
||||
|
||||
@property
|
||||
def latest_array_change(self):
|
||||
return self.obj.history.using("postgres").latest().changes_display_dict["arrayfield"][1]
|
||||
|
||||
def test_changes_display_dict_arrayfield(self):
|
||||
self.assertTrue(self.obj.history.latest().changes_display_dict["arrayfield"][1] == "Red, Green",
|
||||
self.assertTrue(self.latest_array_change == "Red, Green",
|
||||
msg="The human readable text for the two choices, 'Red, Green' is displayed.")
|
||||
self.obj.arrayfield = [PostgresArrayFieldModel.GREEN]
|
||||
self.obj.save()
|
||||
self.assertTrue(self.obj.history.latest().changes_display_dict["arrayfield"][1] == "Green",
|
||||
self.assertTrue(self.latest_array_change == "Green",
|
||||
msg="The human readable text 'Green' is displayed.")
|
||||
self.obj.arrayfield = []
|
||||
self.obj.save()
|
||||
self.assertTrue(self.obj.history.latest().changes_display_dict["arrayfield"][1] == "",
|
||||
self.assertTrue(self.latest_array_change == "",
|
||||
msg="The human readable text '' is displayed.")
|
||||
self.obj.arrayfield = [PostgresArrayFieldModel.GREEN]
|
||||
self.obj.save()
|
||||
self.assertTrue(self.obj.history.latest().changes_display_dict["arrayfield"][1] == "Green",
|
||||
self.assertTrue(self.latest_array_change == "Green",
|
||||
msg="The human readable text 'Green' is displayed.")
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue