

def test_moderate_messages_updates_flags(self):
    'Flags should be updated with moderation action.'
    thread1 = self.create_thread()
    thread2 = self.create_thread()
    message1 = thread1.first_message
    message2 = thread2.first_message
    message1.flag(self.normal_user)
    message1.flag(self.staff_user)
    message2.flag(self.normal_user)
    self.assertEqual(message1.flags.filter(moderation_action__isnull=True).count(), 2)
    self.assertEqual(message2.flags.filter(moderation_action__isnull=True).count(), 1)
    moderate_messages({
        'approved': [message1.pk, message2.pk],
    }, self.superuser)
    self.assertFalse(message1.flags.filter(moderation_action__isnull=True).exists())
    self.assertFalse(message2.flags.filter(moderation_action__isnull=True).exists())

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