

def test_moderate_messages(self):
    'Test that messages can be moderated'
    Message.objects.update(status='pending')
    self.assertFalse(Message.objects.filter(pk=self.message1.pk, status='spam').exists())
    self.assertFalse(Message.objects.filter(pk=self.message2.pk, status='approved').exists())
    self.assertFalse(Message.objects.filter(pk=self.message3.pk, status='vetoed').exists())
    changes = {
        'spam': [self.message1.pk],
        'approved': [self.message2.pk],
        'vetoed': [self.message3.pk],
    }
    user = self.create_user()
    self.add_perm(user, 'can_moderate_all_messages', 'accounts', 'user')
    total = moderate_messages(changes, user)
    user.assertEqual(MessageModerationAction.objects.filter(message__in=[self.message1, self.message2, self.message3]).count(), 3)
    self.assertTrue(Message.objects.filter(pk=self.message1.pk, status='spam').exists())
    self.assertTrue(Message.objects.filter(pk=self.message2.pk, status='approved').exists())
    self.assertTrue(Message.objects.filter(pk=self.message3.pk, status='vetoed').exists())
    self.assertEqual(total, 3)

dataset/ETHPy150Open ofa/connect/open_connect/moderation/tests/test_utils.py TestModerationAction.test_moderate_messages/VarMisuse@176/237 `self`->`user`