Mercurial > public > sg101
view wiki/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 | c4f7f77d55b2 |
children |
line wrap: on
line source
""" Tests for the wiki application tasks. """ from django.test import TestCase from mock import call, patch, ANY, Mock from wiki.tasks import expire_cookies class ExpireCookiesTaskTestCase(TestCase): @patch('wiki.tasks.get_redis_connection') def test_expire_cookies_task(self, connection_mock): redis = Mock() redis.zcard.return_value = 42 redis.zremrangebyscore.return_value = 4 connection_mock.return_value = redis task = expire_cookies.s().apply() self.assertEquals(redis.mock_calls, [ call.zcard('wiki_cookie_keys'), call.zremrangebyscore('wiki_cookie_keys', 0.0, ANY), ])