# HG changeset patch # User Brian Neal # Date 1738899065 21600 # Node ID d18db8bfe17af33500b69f8f7cf0e6bd9f02cacc # Parent b492d640c2858b98b90073b4ceca23907ceff441 Add unit tests for forums tasks. diff -r b492d640c285 -r d18db8bfe17a forums/tests/test_tasks.py --- /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), + ])