annotate forums/tests/test_tasks.py @ 1213:5e898f91fe36 modernize

Add more unit tests for accounts app.
author Brian Neal <bgneal@gmail.com>
date Sun, 09 Feb 2025 14:31:35 -0600
parents d18db8bfe17a
children
rev   line source
bgneal@1212 1 """
bgneal@1212 2 Tests for the forums tasks.
bgneal@1212 3
bgneal@1212 4 """
bgneal@1212 5 from django.test import TestCase
bgneal@1212 6 from mock import call, patch
bgneal@1212 7
bgneal@1212 8 from forums.tasks import new_post_task
bgneal@1212 9 from forums.tasks import updated_post_task
bgneal@1212 10 from forums.tasks import new_topic_task
bgneal@1212 11 from forums.tasks import updated_topic_task
bgneal@1212 12
bgneal@1212 13
bgneal@1212 14 class ForumsTasksTestCase(TestCase):
bgneal@1212 15 @patch('forums.tasks.forums.latest')
bgneal@1212 16 def test_new_post_task(self, latest_mock):
bgneal@1212 17
bgneal@1212 18 new_post_task.s(42).apply()
bgneal@1212 19
bgneal@1212 20 self.assertEquals(latest_mock.mock_calls, [
bgneal@1212 21 call.process_new_post(42),
bgneal@1212 22 ])
bgneal@1212 23
bgneal@1212 24 @patch('forums.tasks.forums.latest')
bgneal@1212 25 def test_updated_post_task(self, latest_mock):
bgneal@1212 26
bgneal@1212 27 updated_post_task.s(42).apply()
bgneal@1212 28
bgneal@1212 29 self.assertEquals(latest_mock.mock_calls, [
bgneal@1212 30 call.process_updated_post(42),
bgneal@1212 31 ])
bgneal@1212 32
bgneal@1212 33 @patch('forums.tasks.forums.latest')
bgneal@1212 34 def test_new_topic_task(self, latest_mock):
bgneal@1212 35
bgneal@1212 36 new_topic_task.s(42).apply()
bgneal@1212 37
bgneal@1212 38 self.assertEquals(latest_mock.mock_calls, [
bgneal@1212 39 call.process_new_topic(42),
bgneal@1212 40 ])
bgneal@1212 41
bgneal@1212 42 @patch('forums.tasks.forums.latest')
bgneal@1212 43 def test_updated_topic_task(self, latest_mock):
bgneal@1212 44
bgneal@1212 45 updated_topic_task.s(42).apply()
bgneal@1212 46
bgneal@1212 47 self.assertEquals(latest_mock.mock_calls, [
bgneal@1212 48 call.process_updated_topic(42),
bgneal@1212 49 ])