Mercurial > public > sg101
comparison core/tests/test_tasks.py @ 1211:b492d640c285 modernize
Added some tests for core.tasks.
Could not get one test to work. :(
author | Brian Neal <bgneal@gmail.com> |
---|---|
date | Thu, 06 Feb 2025 20:58:33 -0600 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
1210:c4f7f77d55b2 | 1211:b492d640c285 |
---|---|
1 """ | |
2 Tests for the core tasks. | |
3 | |
4 """ | |
5 from django.test import TestCase | |
6 from mock import call, patch | |
7 | |
8 from core.tasks import cleanup | |
9 from core.tasks import max_users | |
10 from core.tasks import send_mail | |
11 | |
12 | |
13 class CoreTasksTestCase(TestCase): | |
14 @patch('core.tasks.django.core.mail.EmailMessage') | |
15 def test_send_mail(self, email_mock): | |
16 | |
17 kwargs = {'a': 1, 'b': 2, 'c':3} | |
18 send_mail.s(**kwargs).apply() | |
19 | |
20 self.assertEquals(email_mock.mock_calls, [ | |
21 call(**kwargs), | |
22 call().send(), | |
23 ]) | |
24 | |
25 """ | |
26 Can't get this to work... :( | |
27 @patch('django.contrib.sessions.management.commands.clearsessions') | |
28 @patch('forums.management.commands.forum_cleanup') | |
29 def test_cleanup(self, forum_cleanup_mock, clearsessions_mock): | |
30 | |
31 cleanup.s().apply() | |
32 | |
33 self.assertEquals(clearsessions.mock_calls, [ | |
34 # TODO | |
35 ]) | |
36 self.assertEquals(forum_cleanup_mock.mock_calls, [ | |
37 # TODO | |
38 ]) | |
39 """ | |
40 | |
41 @patch('core.tasks.core.whos_online') | |
42 def test_max_users(self, whos_online_mock): | |
43 | |
44 max_users.s().apply() | |
45 | |
46 self.assertEquals(whos_online_mock.mock_calls, [ | |
47 call.max_users(), | |
48 ]) |