diff options
author | Ruben Pollan <meskio@sindominio.net> | 2015-09-21 19:59:11 +0200 |
---|---|---|
committer | Ruben Pollan <meskio@sindominio.net> | 2015-09-21 19:59:11 +0200 |
commit | 3b0e1694bc3280896a845d92f55590b1553c4a3f (patch) | |
tree | c1cd675bed05503ed69a86a971bea04d7bb90c97 /src | |
parent | 9546348c3603f390fdd6d5a119414142e9bd02ea (diff) |
[style] fix pep8 problems
Diffstat (limited to 'src')
-rw-r--r-- | src/leap/keymanager/__init__.py | 10 | ||||
-rw-r--r-- | src/leap/keymanager/tests/__init__.py | 6 | ||||
-rw-r--r-- | src/leap/keymanager/tests/test_keymanager.py | 14 |
3 files changed, 19 insertions, 11 deletions
diff --git a/src/leap/keymanager/__init__.py b/src/leap/keymanager/__init__.py index 1220402a..5248cb0f 100644 --- a/src/leap/keymanager/__init__.py +++ b/src/leap/keymanager/__init__.py @@ -151,7 +151,8 @@ class KeyManager(object): elif self._ca_cert_path is None: return leap_ca_bundle - tmp_file = tempfile.NamedTemporaryFile(delete=True) # file is auto deleted when python process ends + # file is auto deleted when python process ends + tmp_file = tempfile.NamedTemporaryFile(delete=True) with open(tmp_file.name, 'w') as fout: fin = fileinput.input(files=(leap_ca_bundle, self._ca_cert_path)) @@ -201,8 +202,8 @@ class KeyManager(object): """ Send a GET request to C{uri} containing C{data}. - Instead of using the ca_cert provided on construction time, this version also uses - the default certificates shipped with leap.common + Instead of using the ca_cert provided on construction time, this + version also uses the default certificates shipped with leap.common :param uri: The URI of the request. :type uri: str @@ -212,7 +213,8 @@ class KeyManager(object): :return: The response to the request. :rtype: requests.Response """ - return self._fetcher.get(uri, data=data, verify=self._combined_ca_bundle) + return self._fetcher.get( + uri, data=data, verify=self._combined_ca_bundle) def _put(self, uri, data=None): """ diff --git a/src/leap/keymanager/tests/__init__.py b/src/leap/keymanager/tests/__init__.py index 6b647a4c..9b95e1ac 100644 --- a/src/leap/keymanager/tests/__init__.py +++ b/src/leap/keymanager/tests/__init__.py @@ -76,9 +76,11 @@ class KeyManagerWithSoledadTestCase(unittest.TestCase, BaseLeapTest): d.addCallback(lambda _: self._soledad.close()) return d - def _key_manager(self, user=ADDRESS, url='', token=None, ca_cert_path=None): + def _key_manager(self, user=ADDRESS, url='', token=None, + ca_cert_path=None): return KeyManager(user, url, self._soledad, token=token, - gpgbinary=self.gpg_binary_path, ca_cert_path=ca_cert_path) + gpgbinary=self.gpg_binary_path, + ca_cert_path=ca_cert_path) def _find_gpg(self): gpg_path = distutils.spawn.find_executable('gpg') diff --git a/src/leap/keymanager/tests/test_keymanager.py b/src/leap/keymanager/tests/test_keymanager.py index 984b037a..7c002926 100644 --- a/src/leap/keymanager/tests/test_keymanager.py +++ b/src/leap/keymanager/tests/test_keymanager.py @@ -342,21 +342,24 @@ class KeyManagerKeyManagementTestCase(KeyManagerWithSoledadTestCase): yield km.fetch_key(ADDRESS_OTHER, REMOTE_KEY_URL, OpenPGPKey) - get_mock.assert_called_once_with(REMOTE_KEY_URL, data=None, verify=ca_bundle.where()) + get_mock.assert_called_once_with(REMOTE_KEY_URL, data=None, + verify=ca_bundle.where()) @inlineCallbacks - def test_fetch_key_uses_default_ca_bundle_if_also_set_as_ca_cert_path(self): + def test_fetch_key_uses_default_ca_bundle_if_also_set_as_ca_cert(self): ca_cert_path = ca_bundle.where() km = self._key_manager(ca_cert_path=ca_cert_path) get_mock = self._mock_get_response(km, PUBLIC_KEY_OTHER) yield km.fetch_key(ADDRESS_OTHER, REMOTE_KEY_URL, OpenPGPKey) - get_mock.assert_called_once_with(REMOTE_KEY_URL, data=None, verify=ca_bundle.where()) + get_mock.assert_called_once_with(REMOTE_KEY_URL, data=None, + verify=ca_bundle.where()) @inlineCallbacks def test_fetch_uses_combined_ca_bundle_otherwise(self): - with tempfile.NamedTemporaryFile() as tmp_input, tempfile.NamedTemporaryFile() as tmp_output: + with tempfile.NamedTemporaryFile() as tmp_input, \ + tempfile.NamedTemporaryFile() as tmp_output: ca_content = 'some\ncontent\n' ca_cert_path = tmp_input.name self._dump_to_file(ca_cert_path, ca_content) @@ -369,7 +372,8 @@ class KeyManagerKeyManagementTestCase(KeyManagerWithSoledadTestCase): yield km.fetch_key(ADDRESS_OTHER, REMOTE_KEY_URL, OpenPGPKey) # assert that combined bundle file is passed to get call - get_mock.assert_called_once_with(REMOTE_KEY_URL, data=None, verify=tmp_output.name) + get_mock.assert_called_once_with(REMOTE_KEY_URL, data=None, + verify=tmp_output.name) # assert that files got appended expected = self._slurp_file(ca_bundle.where()) + ca_content |