changeset 1212:d18db8bfe17a modernize tip

Add unit tests for forums tasks.
author Brian Neal <bgneal@gmail.com>
date Thu, 06 Feb 2025 21:31:05 -0600
parents b492d640c285
children
files forums/tests/test_tasks.py
diffstat 1 files changed, 49 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/forums/tests/test_tasks.py	Thu Feb 06 21:31:05 2025 -0600
@@ -0,0 +1,49 @@
+"""
+Tests for the forums tasks.
+
+"""
+from django.test import TestCase
+from mock import call, patch
+
+from forums.tasks import new_post_task
+from forums.tasks import updated_post_task
+from forums.tasks import new_topic_task
+from forums.tasks import updated_topic_task
+
+
+class ForumsTasksTestCase(TestCase):
+    @patch('forums.tasks.forums.latest')
+    def test_new_post_task(self, latest_mock):
+
+        new_post_task.s(42).apply()
+
+        self.assertEquals(latest_mock.mock_calls, [
+            call.process_new_post(42),
+        ])
+
+    @patch('forums.tasks.forums.latest')
+    def test_updated_post_task(self, latest_mock):
+
+        updated_post_task.s(42).apply()
+
+        self.assertEquals(latest_mock.mock_calls, [
+            call.process_updated_post(42),
+        ])
+
+    @patch('forums.tasks.forums.latest')
+    def test_new_topic_task(self, latest_mock):
+
+        new_topic_task.s(42).apply()
+
+        self.assertEquals(latest_mock.mock_calls, [
+            call.process_new_topic(42),
+        ])
+
+    @patch('forums.tasks.forums.latest')
+    def test_updated_topic_task(self, latest_mock):
+
+        updated_topic_task.s(42).apply()
+
+        self.assertEquals(latest_mock.mock_calls, [
+            call.process_updated_topic(42),
+        ])