mirror of
https://github.com/jazzband/django-auditlog.git
synced 2026-03-16 22:20:26 +00:00
[test]: Add test cases to test truncate for unsupported database vendor
This commit is contained in:
parent
abeebf3e5e
commit
e0fb998f0d
1 changed files with 23 additions and 0 deletions
|
|
@ -166,3 +166,26 @@ class AuditlogFlushWithTruncateTest(TransactionTestCase):
|
|||
msg="Output shows warning and table gets truncate",
|
||||
)
|
||||
self.assertEqual(err, "", msg="No stderr")
|
||||
|
||||
@mock.patch(
|
||||
"django.db.connection.vendor",
|
||||
new_callable=mock.PropertyMock(return_value="unknown"),
|
||||
)
|
||||
@mock.patch(
|
||||
"django.db.connection.display_name",
|
||||
new_callable=mock.PropertyMock(return_value="Unknown"),
|
||||
)
|
||||
def test_flush_with_truncate_for_unsupported_database_vendor(
|
||||
self, mocked_vendor, mocked_db_name
|
||||
):
|
||||
obj = self.make_object()
|
||||
self.assertEqual(obj.history.count(), 1, msg="There is one log entry.")
|
||||
out, err = self.call_command("--truncate", "--y")
|
||||
|
||||
self.assertEqual(obj.history.count(), 1, msg="There is still one log entry.")
|
||||
self.assertEqual(
|
||||
out,
|
||||
"Database Unknown does not support truncate statement.",
|
||||
msg="Output shows error",
|
||||
)
|
||||
self.assertEqual(err, "", msg="No stderr")
|
||||
|
|
|
|||
Loading…
Reference in a new issue