Mercurial > public > sg101
comparison wiki/tests/test_tasks.py @ 1210:c4f7f77d55b2 modernize
Add unit test for wiki task.
author | Brian Neal <bgneal@gmail.com> |
---|---|
date | Mon, 03 Feb 2025 16:06:31 -0600 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
1209:d8bb9c36aae1 | 1210:c4f7f77d55b2 |
---|---|
1 """ | |
2 Tests for the wiki application tasks. | |
3 | |
4 """ | |
5 from django.test import TestCase | |
6 from mock import call, patch, ANY, Mock | |
7 | |
8 from wiki.tasks import expire_cookies | |
9 | |
10 | |
11 class ExpireCookiesTaskTestCase(TestCase): | |
12 @patch('wiki.tasks.get_redis_connection') | |
13 def test_expire_cookies_task(self, connection_mock): | |
14 redis = Mock() | |
15 redis.zcard.return_value = 42 | |
16 redis.zremrangebyscore.return_value = 4 | |
17 connection_mock.return_value = redis | |
18 | |
19 task = expire_cookies.s().apply() | |
20 | |
21 self.assertEquals(redis.mock_calls, [ | |
22 call.zcard('wiki_cookie_keys'), | |
23 call.zremrangebyscore('wiki_cookie_keys', 0.0, ANY), | |
24 ]) |