Mercurial > public > sg101
view 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 |
line wrap: on
line source
""" 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), ])