

def test_non_superuser_needs_correct_permissions_to_moderate(self):
    'Test that non-superusers need correct permissions for moderation'
    Message.objects.update(status='pending')
    newuser = mommy.make(get_user_model())
    newuser.add_to_group(self.group2.pk)
    self.group2.owners.add(newuser)
    self.assertIn(self.message3.thread.group, newuser.groups_moderating)
    self.assertNotIn(self.message1.thread.group, newuser.groups_moderating)
    changes = {
        'spam': [self.message1.pk],
        'approved': [self.message3.pk],
    }
    total = moderate_messages(changes, newuser)
    self.assertTrue(self.message3.messagemoderationaction_set.filter(newstatus='approved').exists())
    self.assertEqual(total, 1)
    message1 = Message.objects.get(pk=self.message1.pk)
    self.assertEqual(message1.status, 'pending')

dataset/ETHPy150Open ofa/connect/open_connect/moderation/tests/test_utils.py TestModerationAction.test_non_superuser_needs_correct_permissions_to_moderate/original