diff options
author | Folker Bernitt <fbernitt@thoughtworks.com> | 2016-01-18 15:39:59 +0100 |
---|---|---|
committer | Folker Bernitt <fbernitt@thoughtworks.com> | 2016-01-18 15:39:59 +0100 |
commit | c5d61bc8001b16e3dcedda9fd1229c27cca4bd3b (patch) | |
tree | a36fb87a31b7692d124b959ba32ba49f48a14ed8 /service/test/unit | |
parent | 0b06feff629f91d2fa4e7bdbe3b8e46b412e6158 (diff) |
Refactory KeyResource to get services from session
- Issue #576
- Only first step (other services not changed yet)
- Faked session access for now
Diffstat (limited to 'service/test/unit')
-rw-r--r-- | service/test/unit/resources/test_keys_resources.py | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/service/test/unit/resources/test_keys_resources.py b/service/test/unit/resources/test_keys_resources.py index 1990efe8..a737bc16 100644 --- a/service/test/unit/resources/test_keys_resources.py +++ b/service/test/unit/resources/test_keys_resources.py @@ -1,7 +1,9 @@ import json import ast -from mockito import mock, when +from mockito import mock, when, any as ANY from leap.keymanager import OpenPGPKey, KeyNotFound + +from pixelated.application import ServicesFactory from pixelated.resources.keys_resource import KeysResource import twisted.trial.unittest as unittest from twisted.web.test.requesthelper import DummyRequest @@ -13,7 +15,12 @@ class TestKeysResource(unittest.TestCase): def setUp(self): self.keymanager = mock() - self.web = DummySite(KeysResource(self.keymanager)) + self.servicesFactory = mock() + self.services = mock() + self.services.keymanager = self.keymanager + self.servicesFactory._services_by_user = {'someuserid': self.keymanager} + when(self.servicesFactory).services(ANY()).thenReturn(self.services) + self.web = DummySite(KeysResource(self.servicesFactory)) def test_returns_404_if_key_not_found(self): request = DummyRequest(['/keys']) |