예제 #1
0
    def test_old_version_of_filter_moderated_objects_method(self):
        m1 = ModelWithSlugField(slug='test')
        m1.save()

        m2 = ModelWithSlugField(slug='test')
        self.assertRaises(IntegrityError, m2.save)

        self.assertEqual(ModeratedObject.objects.all().count(), 1)
예제 #2
0
    def test_raise_integrity_error_model_registered_with_moderation(self):
        m1 = ModelWithSlugField(slug='test')
        m1.save()

        self.assertRaises(ObjectDoesNotExist, ModelWithSlugField.objects.get,
                          slug='test')

        m2 = ModelWithSlugField(slug='test')
        self.assertRaises(IntegrityError, m2.save)

        self.assertEqual(ModeratedObject.objects.all().count(), 1)
예제 #3
0
class ContentTypeFilterSpecTextCase(SettingsTestCase):
    fixtures = ['test_users.json', 'test_moderation.json']
    urls = 'moderation.tests.test_urls'
    test_settings = 'moderation.tests.settings.generic'

    def setUp(self):
        from moderation.tests import setup_moderation
        rf = RequestFactory()
        rf.login(username='******', password='******')
        self.request = rf.get('/admin/moderation/')
        self.request.user = User.objects.get(username='******')
        self.admin = ModerationAdmin(UserProfile, site)

        models = [ModelWithSlugField, ModelWithSlugField2]
        self.new_moderation, self.old_moderation = setup_moderation(models)
        
        self.m1 = ModelWithSlugField(slug='test')
        self.m1.save()
        
        self.m2 = ModelWithSlugField2(slug='test')
        self.m2.save()
        
    def tearDown(self):
        from moderation.tests import teardown_moderation
        teardown_moderation(self.new_moderation, self.old_moderation,
                            [ModelWithSlugField, ModelWithSlugField2])
        
    def test_content_types(self):
        f = ModeratedObject._meta.get_field('content_type')
        filter_spec = ContentTypeFilterSpec(f, self.request, {},
                                            ModeratedObject, self.admin)
        
        self.assertEqual([x[1] for x in filter_spec.lookup_choices],
                         [u'Model with slug field',
                          u'Model with slug field2'])
        
        self.assertEqual(unicode(filter_spec.content_types),
                         u"[<ContentType: model with slug field>, "\
                         "<ContentType: model with slug field2>]")
예제 #4
0
    def setUp(self):
        from moderation.tests import setup_moderation
        rf = RequestFactory()
        rf.login(username='******', password='******')
        self.request = rf.get('/admin/moderation/')
        self.request.user = User.objects.get(username='******')
        self.admin = ModerationAdmin(UserProfile, site)

        models = [ModelWithSlugField, ModelWithSlugField2]
        self.new_moderation, self.old_moderation = setup_moderation(models)
        
        self.m1 = ModelWithSlugField(slug='test')
        self.m1.save()
        
        self.m2 = ModelWithSlugField2(slug='test')
        self.m2.save()