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)
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)
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 = [ModelWithSlugField2, ModelWithSlugField] self.moderation = setup_moderation(models) self.m1 = ModelWithSlugField(slug='test') self.m1.save() self.m2 = ModelWithSlugField2(slug='test') self.m2.save()
class ContentTypeFilterSpecTextCase(SettingsTestCase): fixtures = ["test_users.json", "test_moderation.json"] urls = "moderation.tests.urls.default" 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 = [ModelWithSlugField2, ModelWithSlugField] self.moderation = setup_moderation(models) self.m1 = ModelWithSlugField(slug="test") self.m1.save() self.m2 = ModelWithSlugField2(slug="test") self.m2.save() def tearDown(self): teardown_moderation() def test_content_types_and_its_order(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>]", )
class ContentTypeFilterSpecTextCase(SettingsTestCase): fixtures = ['test_users.json', 'test_moderation.json'] urls = 'moderation.tests.urls.default' 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 = [ModelWithSlugField2, ModelWithSlugField] self.moderation = setup_moderation(models) self.m1 = ModelWithSlugField(slug='test') self.m1.save() self.m2 = ModelWithSlugField2(slug='test') self.m2.save() def tearDown(self): teardown_moderation() def test_content_types_and_its_order(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>]")
class ContentTypeFilterSpecTextCase(SettingsTestCase): fixtures = ['test_users.json', 'test_moderation.json'] urls = 'moderation.tests.urls.default' 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.moderation = setup_moderation(models) self.m1 = ModelWithSlugField(slug='test') self.m1.save() self.m2 = ModelWithSlugField2(slug='test') self.m2.save() def tearDown(self): teardown_moderation() 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>]")
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.moderation = setup_moderation(models) self.m1 = ModelWithSlugField(slug='test') self.m1.save() self.m2 = ModelWithSlugField2(slug='test') self.m2.save()