Commit 8570d70eafa98d6f56464549a2c8b4f9e3aea01f
1 parent
bf316bce
Exists in
master
and in
30 other branches
Create test for signals on colab.plugins.utils
Signed-off-by: Lucas Kanashiro <kanashiro.duarte@gmail.com>
Showing
3 changed files
with
20 additions
and
1 deletions
Show diff stats
@@ -0,0 +1,20 @@ | @@ -0,0 +1,20 @@ | ||
1 | +from django.test import TestCase | ||
2 | +from mock import patch, MagicMock | ||
3 | +from colab.plugins.utils import signals | ||
4 | + | ||
5 | + | ||
6 | +class SignalsTest(TestCase): | ||
7 | + @patch("colab.plugins.utils.signals.apps.get_app_configs") | ||
8 | + def test_init_signals(self, mock_app): | ||
9 | + method_name = 'test' | ||
10 | + | ||
11 | + app_mock = MagicMock() | ||
12 | + | ||
13 | + apps_list = ['a', 'b', app_mock] | ||
14 | + | ||
15 | + mock_app.return_value = apps_list | ||
16 | + signals._init_signals(method_name) | ||
17 | + | ||
18 | + app_mock.test.assert_called_with(app_mock) | ||
19 | + self.assertEqual(1, app_mock.test.call_count) | ||
20 | + self.assertTrue(app_mock.test.called) |
colab/signals/tests/test_signals.py
@@ -16,7 +16,6 @@ from ..exceptions import SignalDoesNotExist | @@ -16,7 +16,6 @@ from ..exceptions import SignalDoesNotExist | ||
16 | class SignalsTest(TestCase): | 16 | class SignalsTest(TestCase): |
17 | 17 | ||
18 | def setUp(self): | 18 | def setUp(self): |
19 | - django.setup() | ||
20 | self.list_signal = ['a', 'b', 'c'] | 19 | self.list_signal = ['a', 'b', 'c'] |
21 | self.plugin_name = 'test_signal' | 20 | self.plugin_name = 'test_signal' |
22 | 21 |