Beispiel #1
0
 def test_unchanged_data(self):
     """
     Test to determine if correct value is generated if a field has not changed.
     """
     from django_contenthistory.handlers import BaseHistoryHandler
     
     handler = BaseHistoryHandler(ContentType.objects.get_for_model(User))
     current_user = User(username = '******')
     final_user = User(username = '******')
     target_field = ModelField(name = 'username', mode = ModelField.TEXT, content = self.tracked_content)
     target_field.save()
     created, object_id, data, modified = handler.get_data(current_user, final_user)
     self.assertFalse(modified)
     self.assertFalse(created)
     target_field.delete()
Beispiel #2
0
 def test_base_handler(self):
     """
     Tests the standard handler for data handling and tracked content
     registration.
     """
     from django_contenthistory.handlers import BaseHistoryHandler
     
     handler = BaseHistoryHandler(ContentType.objects.get_for_model(User))
     current_user = User(username = '******')
     final_user = User(username = '******')
     target_field = ModelField(name = 'username', mode = ModelField.TEXT, content = self.tracked_content)
     target_field.save()
     created, object_id, data, modified = handler.get_data(current_user, final_user)
     self.assertTrue(modified)
     self.assertFalse(created)
     self.assertEqual(json.loads(data).get('username'), utils.generate_diff('genghisu', 'hanbox'))
     target_field.delete()