summaryrefslogtreecommitdiff
path: root/src/leap/common/tests/test_keymanager.py
diff options
context:
space:
mode:
authordrebs <drebs@leap.se>2013-05-14 15:53:04 -0300
committerdrebs <drebs@leap.se>2013-05-14 15:53:04 -0300
commitadc5bb1c8e6ff5bada17e27ed772dee1ba424b28 (patch)
treec65b2c7f8b2a9a2cdc85ce3fca8726868d8f4d48 /src/leap/common/tests/test_keymanager.py
parent42d46aae15fcdda803b4dc8e3e2f37f6e695f09d (diff)
Add dependency on soledad and install tests.
Diffstat (limited to 'src/leap/common/tests/test_keymanager.py')
-rw-r--r--src/leap/common/tests/test_keymanager.py20
1 files changed, 9 insertions, 11 deletions
diff --git a/src/leap/common/tests/test_keymanager.py b/src/leap/common/tests/test_keymanager.py
index e52766a..68a30e7 100644
--- a/src/leap/common/tests/test_keymanager.py
+++ b/src/leap/common/tests/test_keymanager.py
@@ -21,7 +21,7 @@ Tests for the Key Manager.
"""
-import mock
+from mock import Mock
try:
import simplejson as json
except ImportError:
@@ -141,6 +141,11 @@ class KeyManagerUtilTestCase(BaseLeapTest):
class KeyManagerWithSoledadTestCase(BaseLeapTest):
def setUp(self):
+ # mock key fetching and storing so Soledad doesn't fail when trying to
+ # reach the server.
+ Soledad._fetch_keys_from_shared_db = Mock(return_value=None)
+ Soledad._assert_keys_in_shared_db = Mock(return_value=None)
+
self._soledad = Soledad(
"leap@leap.se",
"123456",
@@ -148,14 +153,7 @@ class KeyManagerWithSoledadTestCase(BaseLeapTest):
local_db_path=self.tempdir+"/soledad.u1db",
server_url='',
cert_file=None,
- bootstrap=False,
)
- # initialize solead by hand for testing purposes
- self._soledad._init_dirs()
- self._soledad._crypto = SoledadCrypto(self._soledad)
- self._soledad._shared_db = None
- self._soledad._init_keys()
- self._soledad._init_db()
def tearDown(self):
km = self._key_manager()
@@ -450,7 +448,7 @@ class KeyManagerKeyManagementTestCase(
def test_send_public_key(self):
km = self._key_manager()
km._wrapper_map[OpenPGPKey].put_ascii_key(PUBLIC_KEY)
- km._fetcher.put = mock.Mock()
+ km._fetcher.put = Mock()
km.token = '123'
km.send_key(OpenPGPKey, send_private=False)
# setup args
@@ -478,7 +476,7 @@ class KeyManagerKeyManagementTestCase(
def json(self):
return {'address': 'anotheruser@leap.se', 'keys': []}
- km._fetcher.get = mock.Mock(
+ km._fetcher.get = Mock(
return_value=Response())
# do the fetch
km.fetch_keys_from_server('anotheruser@leap.se')
@@ -491,7 +489,7 @@ class KeyManagerKeyManagementTestCase(
# TODO: maybe we should not attempt to refresh our own public key?
km = self._key_manager()
km._wrapper_map[OpenPGPKey].put_ascii_key(PUBLIC_KEY)
- km.fetch_keys_from_server = mock.Mock(return_value=[])
+ km.fetch_keys_from_server = Mock(return_value=[])
km.refresh_keys()
km.fetch_keys_from_server.assert_called_once_with(
'leap@leap.se'