Commit 5af82b0ad4557a8ff7ef13d3dfdf912067b5f802

Authored by Lucas Moura
Committed by Sergio Oliveira
1 parent 7b743f36

Fixing signals test

Changing the name of the file imported by the test and also using PropertyMock
to mock the delay attribute for the handling method attribute for the
connect_signal method

Signed-off-by: Lucas Kanashiro <kanashiro.duarte@gmail.com>
colab/plugins/utils/apps.py
... ... @@ -10,7 +10,7 @@ class ColabProxiedAppConfig(AppConfig):
10 10  
11 11 def __init__(self, app_name, app_module):
12 12 super(ColabProxiedAppConfig, self).__init__(app_name, app_module)
13   - self.__import_signals(app_name)
  13 + self._import_signals(app_name)
14 14 self.signals.register_signal()
15 15  
16 16  
... ...
colab/signals/tests/test_signals.py
... ... @@ -6,8 +6,8 @@ Objective: Test parameters, and behavior.
6 6 from django.test import TestCase
7 7 from django.apps import apps
8 8 import django
9   -from colab.signals.tasks import *
10   -from mock import patch
  9 +from colab.signals.signals import *
  10 +from mock import patch, MagicMock, PropertyMock
11 11  
12 12  
13 13 class SignalsTest(TestCase):
... ... @@ -51,12 +51,13 @@ class SignalsTest(TestCase):
51 51 @patch('colab.signals.signals.Signal.connect')
52 52 def test_connect_already_registered_signal(self, mock):
53 53 sender = 'Test'
54   - handling_method = 'Test'
  54 + handling_method = MagicMock
  55 + type(handling_method).delay = PropertyMock(return_value='Test')
55 56 signal_name = 'a'
56 57  
57 58 register_signal(self.plugin_name, self.list_signal)
58 59  
59   - connect_signal(signal_name, sender, handling_method)
  60 + connect_signal(signal_name, sender, handling_method.delay)
60 61 args, kwargs = mock.call_args
61 62  
62 63 self.assertEqual(args[0], handling_method)
... ...