allianceauth/services/tests/test_tasks.py
Adarnof 00cc89d71c Merge branch 'master' of https://github.com/Adarnof/allianceauth into custom_user
# Conflicts:
#	alliance_auth/settings.py.example
#	eveonline/views.py

Fix some tests.
2017-05-27 18:34:59 -04:00

34 lines
934 B
Python

from __future__ import unicode_literals
try:
# Py3
from unittest import mock
except ImportError:
# Py2
import mock
from django.test import TestCase
from alliance_auth.tests.auth_utils import AuthUtils
from services.tasks import validate_services
class ServicesTasksTestCase(TestCase):
def setUp(self):
self.member = AuthUtils.create_user('auth_member')
@mock.patch('services.tasks.ServicesHook')
def test_validate_services(self, services_hook):
svc = mock.Mock()
svc.validate_user.return_value = None
services_hook.get_services.return_value = [svc]
validate_services.delay(user=self.member)
self.assertTrue(services_hook.get_services.called)
self.assertTrue(svc.validate_user.called)
args, kwargs = svc.validate_user.call_args
self.assertEqual(self.member, args[0]) # Assert correct user is passed to service hook function