Commit b64ce544 authored by Daniel Klaffenbach's avatar Daniel Klaffenbach 🐍

tests: Add tests for `operation` attribute

parent 6f5aca2d
Pipeline #8402 passed with stage
in 1 minute and 16 seconds
......@@ -10,6 +10,10 @@ class JournalEntryTestCase(TransactionTestCase):
self.related_object = RelatedTestModel.objects.create(char_field="Foo")
def _create_test_model(self):
"""
:rtype: TestModel
:return: A new TestModel instance
"""
obj = TestModel()
obj.char_field = "test"
obj.int_field = 1
......@@ -62,3 +66,18 @@ class JournalEntryTestCase(TransactionTestCase):
'int_field': (1, 2)
}
self.assertEqual(updated_entry.get_diff(), expected_diff)
def test_journal_entry_operation(self):
""" Tests if the `operation` attribute is set correctly."""
obj = self._create_test_model()
last_journal = JournalEntry.objects.last()
self.assertEqual(last_journal.operation, JournalEntry.OPERATION_ADD)
obj.int_field += 1
obj.save()
last_journal = JournalEntry.objects.last()
self.assertEqual(last_journal.operation, JournalEntry.OPERATION_CHANGE)
TestModel.objects.all().delete()
last_journal = JournalEntry.objects.last()
self.assertEqual(last_journal.operation, JournalEntry.OPERATION_DELETE)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment