Beispiel #1
0
    def test_send_message_when_object_has_no_moderated_object(self):
        profile = SuperUserProfile(description='Profile for new user',
                    url='http://www.yahoo.com',
                    user=User.objects.get(username='******'),
                    super_power='text')

        profile.save()

        self.moderation.register(SuperUserProfile)

        self.admin.send_message(self.request, profile.pk)

        message = self.request.user.message_set.get()
        self.assertEqual(unicode(message), u"This object is not registered "\
                                          u"with the moderation system.")
Beispiel #2
0
    def test_serialize_with_inheritance(self):
        """Test if object is properly serialized to json"""

        profile = SuperUserProfile(description='Profile for new super user',
                    url='http://www.test.com',
                    user=User.objects.get(username='******'),
                    super_power='invisibility')
        profile.save()
        json_field = SerializedObjectField()
        
        self.assertEqual(json_field._serialize(profile),
                        '[{"pk": 2, "model": "test_app1.superuserprofile",'\
                        ' "fields": {"super_power": "invisibility"}}, '\
                        '{"pk": 2, "model": "test_app1.userprofile", "fields":'\
                        ' {"url": "http://www.test.com", "user": 2,'\
                        ' "description": "Profile for new super user"}}]')
Beispiel #3
0
    def test_send_message_when_object_has_no_moderated_object(self):
        profile = SuperUserProfile(description='Profile for new user',
                                   url='http://www.yahoo.com',
                                   user=User.objects.get(username='******'),
                                   super_power='text')

        profile.save()

        self.moderation.register(SuperUserProfile)

        self.admin.send_message(self.request, profile.pk)

        args, kwargs = self.request._messages.add.call_args
        level, message, tags = args
        self.assertEqual(unicode(message), u"This object is not registered "\
                                           u"with the moderation system.")
Beispiel #4
0
    def test_serialize_with_inheritance(self):
        """Test if object is properly serialized to json"""

        profile = SuperUserProfile(description='Profile for new super user',
                                   url='http://www.test.com',
                                   user=User.objects.get(username='******'),
                                   super_power='invisibility')
        profile.save()
        json_field = SerializedObjectField()

        self.assertEqual(
            json_field._serialize(profile),
            '[{"pk": 2, "model": "test_app1.superuserprofile",'\
            ' "fields": {"super_power": "invisibility"}}, '\
            '{"pk": 2, "model": "test_app1.userprofile", "fields":'\
            ' {"url": "http://www.test.com", "user": 2,'\
            ' "description": "Profile for new super user"}}]')