예제 #1
0
class ModeratedObjectAdminTestCase(TestCase):
    fixtures = ["test_users.json"]
    urls = "moderation.tests.urls.default"

    def setUp(self):
        rf = RequestFactory()
        rf.login(username="******", password="******")
        self.request = rf.get("/admin/moderation/")
        self.request.user = User.objects.get(username="******")
        self.admin = ModeratedObjectAdmin(ModeratedObject, site)

        for user in User.objects.all():
            ModeratedObject(content_object=user).save()

    def test_get_actions_should_not_return_delete_selected(self):
        actions = self.admin.get_actions(self.request)
        self.failIfEqual("delete_selected" in actions, True)

    def test_content_object_returns_deserialized_object(self):
        user = User.objects.get(username="******")
        moderated_object = ModeratedObject(content_object=user)
        moderated_object.save()
        content_object = self.admin.content_object(moderated_object)
        self.assertEqual(content_object, "admin")

    def test_get_moderated_object_form(self):
        form = self.admin.get_moderated_object_form(UserProfile)
        self.assertEqual(repr(form), "<class 'moderation.admin.ModeratedObjectForm'>")
예제 #2
0
class ModeratedObjectAdminTestCase(TestCase):
    fixtures = ['test_users.json']

    def setUp(self):
        rf = RequestFactory()
        rf.login(username='******', password='******')
        self.request = rf.get('/admin/moderation/')
        self.request.user = User.objects.get(username='******')
        self.admin = ModeratedObjectAdmin(ModeratedObject, site)

        for user in User.objects.all():
            ModeratedObject(content_object=user).save()

    def test_get_actions_should_not_return_delete_selected(self):
        actions = self.admin.get_actions(self.request)
        self.failIfEqual('delete_selected' in actions, True)

    def test_content_object_returns_deserialized_object(self):
        user = User.objects.get(username='******')
        moderated_object = ModeratedObject(content_object=user)
        moderated_object.save()
        content_object = self.admin.content_object(moderated_object)
        self.assertEqual(content_object, "admin")

    def test_get_moderated_object_form(self):
        form = self.admin.get_moderated_object_form(UserProfile)
        self.assertIn('ModeratedObjectForm', repr(form))
class ModeratedObjectAdminTestCase(TestCase):
    fixtures = ['test_users.json']

    def setUp(self):
        rf = RequestFactory()
        rf.login(username='******', password='******')
        self.request = rf.get('/admin/moderation/')
        self.request.user = User.objects.get(username='******')
        self.admin = ModeratedObjectAdmin(ModeratedObject, site)

        for user in User.objects.all():
            ModeratedObject(content_object=user).save()

    def test_get_actions_should_not_return_delete_selected(self):
        actions = self.admin.get_actions(self.request)
        self.failIfEqual('delete_selected' in actions, True)

    def test_content_object_returns_deserialized_object(self):
        user = User.objects.get(username='******')
        moderated_object = ModeratedObject(content_object=user)
        moderated_object.save()
        content_object = self.admin.content_object(moderated_object)
        self.assertEqual(content_object, "admin")

    def test_get_moderated_object_form(self):
        form = self.admin.get_moderated_object_form(UserProfile)
        self.assertIn('ModeratedObjectForm', repr(form))
예제 #4
0
    def setUp(self):
        rf = RequestFactory()
        rf.login(username='******', password='******')
        self.request = rf.get('/admin/moderation/')
        self.request.user = User.objects.get(username='******')
        self.admin = ModeratedObjectAdmin(ModeratedObject, site)

        for user in User.objects.all():
            ModeratedObject(content_object=user).save()
예제 #5
0
    def setUp(self):
        rf = RequestFactory()
        rf.login(username="******", password="******")
        self.request = rf.get("/admin/moderation/")
        self.request.user = User.objects.get(username="******")
        self.admin = ModeratedObjectAdmin(ModeratedObject, site)

        for user in User.objects.all():
            ModeratedObject(content_object=user).save()
예제 #6
0
 def setUp(self):
     rf = RequestFactory()
     rf.login(username='******', password='******')
     self.request = rf.get('/admin/moderation/')
     self.request.user = User.objects.get(username='******')
     self.admin = ModeratedObjectAdmin(ModeratedObject, site)
     
     for user in User.objects.all():
         ModeratedObject(content_object=user).save()
         
     self.moderated_objects = ModeratedObject.objects.all()
예제 #7
0
class AdminActionsTestCase(TestCase):
    fixtures = ['test_users.json']
    urls = 'moderation.tests.test_urls'

    def setUp(self):
        rf = RequestFactory()
        rf.login(username='******', password='******')
        self.request = rf.get('/admin/moderation/')
        self.request.user = User.objects.get(username='******')
        self.admin = ModeratedObjectAdmin(ModeratedObject, site)

        self.moderation = setup_moderation([User])

        for user in User.objects.all():
            ModeratedObject(content_object=user).save()

        self.moderated_objects = ModeratedObject.objects.all()

    def tearDown(self):
        teardown_moderation()

    def test_queryset_should_return_only_moderation_ready_objects(self):
        qs = self.admin.queryset(self.request)
        qs = qs.filter(moderation_state=MODERATION_DRAFT_STATE)
        self.assertEqual(list(qs), [])

    def test_approve_objects(self):
        approve_objects(self.admin, self.request, self.moderated_objects)

        for obj in ModeratedObject.objects.all():
            self.assertEqual(obj.moderation_status,
                             MODERATION_STATUS_APPROVED)

    def test_reject_objects(self):
        qs = ModeratedObject.objects.all()

        reject_objects(self.admin, self.request, qs)

        for obj in ModeratedObject.objects.all():
            self.assertEqual(obj.moderation_status,
                             MODERATION_STATUS_REJECTED)

    def test_set_objects_as_pending(self):
        for obj in self.moderated_objects:
            obj.approve(moderated_by=self.request.user)

        set_objects_as_pending(self.admin, self.request,
                               self.moderated_objects)

        for obj in ModeratedObject.objects.all():
            self.assertEqual(obj.moderation_status,
                             MODERATION_STATUS_PENDING)