diff options
author | NavaL <mnandri@thoughtworks.com> | 2016-01-18 17:27:19 +0100 |
---|---|---|
committer | NavaL <mnandri@thoughtworks.com> | 2016-01-18 17:27:19 +0100 |
commit | bb9a1c8827c02ac71c16b7d5d0b4c4c18b34f24c (patch) | |
tree | 7027cf3f00276753c12514864c9527459063d77a /service/test | |
parent | c5d61bc8001b16e3dcedda9fd1229c27cca4bd3b (diff) |
migrating AttachmentsResources to use the service factory
Issue #576
Diffstat (limited to 'service/test')
-rw-r--r-- | service/test/support/integration/app_test_client.py | 1 | ||||
-rw-r--r-- | service/test/unit/resources/test_attachments_resource.py | 10 |
2 files changed, 9 insertions, 2 deletions
diff --git a/service/test/support/integration/app_test_client.py b/service/test/support/integration/app_test_client.py index 16344171..6a43ed1a 100644 --- a/service/test/support/integration/app_test_client.py +++ b/service/test/support/integration/app_test_client.py @@ -90,6 +90,7 @@ class AppTestClient(object): self.service_factory = ServicesFactory() services = mock() services.keymanager = self.keymanager + services.mail_service = self.mail_service self.service_factory.add_session('someuserid', services) self.resource.initialize( diff --git a/service/test/unit/resources/test_attachments_resource.py b/service/test/unit/resources/test_attachments_resource.py index 8beb02fa..f3d8ce53 100644 --- a/service/test/unit/resources/test_attachments_resource.py +++ b/service/test/unit/resources/test_attachments_resource.py @@ -3,7 +3,7 @@ import unittest import logging from mock import patch, MagicMock -from mockito import mock, when, verify +from mockito import mock, when, verify, any as ANY from twisted.internet import defer from twisted.web.test.requesthelper import DummyRequest @@ -17,7 +17,13 @@ class AttachmentsResourceTest(unittest.TestCase): def setUp(self): self.mail_service = mock() - self.mails_resource = AttachmentsResource(self.mail_service) + self.servicesFactory = mock() + self.services = mock() + self.services.mail_service = self.mail_service + self.servicesFactory._services_by_user = {'someuserid': self.mail_service} + when(self.servicesFactory).services(ANY()).thenReturn(self.services) + + self.mails_resource = AttachmentsResource(self.servicesFactory) self.mails_resource.isLeaf = True self.web = DummySite(self.mails_resource) |