comparison forums/tests/test_tasks.py @ 1212:d18db8bfe17a modernize

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