

def test_moderating_updates_total_messages(self):
    'thread.total_messages should be updated when saving.'
    flag_user = self.create_user()
    superuser = self.create_superuser()
    thread_to_approve = self.create_thread()
    thread_to_approve.first_message.flag(flag_user)
    flag_user.total_messages = 0
    thread_to_approve.save()
    thread_to_veto = self.create_thread()
    thread_to_veto.first_message.flag(flag_user)
    thread_to_veto.total_messages = 1
    thread_to_veto.save()
    self.assertEqual(thread_to_approve.total_messages, 0)
    self.assertEqual(thread_to_veto.total_messages, 1)
    moderate_messages({
        'approved': [thread_to_approve.first_message.pk],
        'veto': [thread_to_veto.first_message.pk],
    }, superuser)
    thread_to_approve = Thread.objects.get(pk=thread_to_approve.pk)
    thread_to_veto = Thread.objects.get(pk=thread_to_veto.pk)
    self.assertEqual(thread_to_approve.total_messages, 1)
    self.assertEqual(thread_to_veto.total_messages, 0)

dataset/ETHPy150Open ofa/connect/open_connect/moderation/tests/test_utils.py TestModerationAction.test_moderating_updates_total_messages/VarMisuse@45/86 `thread_to_approve`->`flag_user`