Completed test coverage for admin's LogEntry model.

This commit is contained in:
Anton Samarchyan 2017-06-19 13:42:05 -04:00 committed by Tim Graham
parent fda55c71a8
commit 0b9ccf9e60
1 changed files with 9 additions and 0 deletions

View File

@ -67,6 +67,11 @@ class LogEntryTests(TestCase):
with translation.override('fr'): with translation.override('fr'):
self.assertEqual(logentry.get_change_message(), 'Ajout.') self.assertEqual(logentry.get_change_message(), 'Ajout.')
def test_logentry_change_message_not_json(self):
"""LogEntry.change_message was a string before Django 1.10."""
logentry = LogEntry(change_message='non-JSON string')
self.assertEqual(logentry.get_change_message(), logentry.change_message)
@override_settings(USE_L10N=True) @override_settings(USE_L10N=True)
def test_logentry_change_message_localized_datetime_input(self): def test_logentry_change_message_localized_datetime_input(self):
""" """
@ -177,6 +182,10 @@ class LogEntryTests(TestCase):
log_entry.action_flag = 4 log_entry.action_flag = 4
self.assertEqual(str(log_entry), 'LogEntry Object') self.assertEqual(str(log_entry), 'LogEntry Object')
def test_logentry_repr(self):
logentry = LogEntry.objects.first()
self.assertEqual(repr(logentry), str(logentry.action_time))
def test_log_action(self): def test_log_action(self):
content_type_pk = ContentType.objects.get_for_model(Article).pk content_type_pk = ContentType.objects.get_for_model(Article).pk
log_entry = LogEntry.objects.log_action( log_entry = LogEntry.objects.log_action(