diff options
author | Victor Shyba <victor.shyba@gmail.com> | 2015-08-04 14:30:30 -0300 |
---|---|---|
committer | Folker Bernitt <fbernitt@thoughtworks.com> | 2015-08-11 17:00:31 +0200 |
commit | 77cb8b69610a893becd99286d85633e5317fedd2 (patch) | |
tree | fe91a5efa2ae4e3383d263a7b4cdb7f3e4ce04be | |
parent | 5862cb1db30fe4b748427cae663d4f3be3dd7af8 (diff) |
[tests] mock update to reflect deferreds returned
Calls to get_key now returns deferreds, so mocks need to do the same.
Also, underlying call changed.
-- Issue #422
-rw-r--r-- | service/test/unit/resources/test_keys_resources.py | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/service/test/unit/resources/test_keys_resources.py b/service/test/unit/resources/test_keys_resources.py index 71a6415a..1990efe8 100644 --- a/service/test/unit/resources/test_keys_resources.py +++ b/service/test/unit/resources/test_keys_resources.py @@ -5,6 +5,7 @@ from leap.keymanager import OpenPGPKey, KeyNotFound from pixelated.resources.keys_resource import KeysResource import twisted.trial.unittest as unittest from twisted.web.test.requesthelper import DummyRequest +from twisted.internet import defer from test.unit.resources import DummySite @@ -17,7 +18,7 @@ class TestKeysResource(unittest.TestCase): def test_returns_404_if_key_not_found(self): request = DummyRequest(['/keys']) request.addArg('search', 'some@inexistent.key') - when(self.keymanager).get_key_from_cache('some@inexistent.key', OpenPGPKey).thenRaise(KeyNotFound()) + when(self.keymanager).fetch_key('some@inexistent.key').thenReturn(defer.fail(KeyNotFound())) d = self.web.get(request) @@ -30,7 +31,7 @@ class TestKeysResource(unittest.TestCase): def test_returns_the_key_as_json_if_found(self): request = DummyRequest(['/keys']) request.addArg('search', 'some@key') - when(self.keymanager).get_key_from_cache('some@key', OpenPGPKey).thenReturn(OpenPGPKey('some@key')) + when(self.keymanager).fetch_key('some@key').thenReturn(defer.succeed(OpenPGPKey('some@key'))) d = self.web.get(request) @@ -61,7 +62,7 @@ class TestKeysResource(unittest.TestCase): def test_returns_unauthorized_if_key_is_private(self): request = DummyRequest(['/keys']) request.addArg('search', 'some@key') - when(self.keymanager).get_key_from_cache('some@key', OpenPGPKey).thenReturn(OpenPGPKey('some@key', private=True)) + when(self.keymanager).fetch_key('some@key').thenReturn(defer.succeed(OpenPGPKey('some@key', private=True))) d = self.web.get(request) |