diff options
author | Bruno Wagner Goncalves <bwagner@thoughtworks.com> | 2014-08-18 19:14:55 -0300 |
---|---|---|
committer | Bruno Wagner Goncalves <bwagner@thoughtworks.com> | 2014-08-18 19:15:05 -0300 |
commit | 2c6fe6e4cca9c39287c0c9a88079a60078711e97 (patch) | |
tree | 9cd73392e3fc5646dca87bbefc758c9c975f4558 /service/test | |
parent | 3cc37ad518706c7abe61d3d3cd7b91798901cc5b (diff) |
Fixed pep8 errors on service
Diffstat (limited to 'service/test')
-rw-r--r-- | service/test/__init__.py | 1 | ||||
-rw-r--r-- | service/test/adapter/test_helper.py | 11 | ||||
-rw-r--r-- | service/test/bitmask_libraries/leap_srp_test.py | 7 | ||||
-rw-r--r-- | service/test/bitmask_libraries/nicknym_test.py | 10 | ||||
-rw-r--r-- | service/test/bitmask_libraries/provider_test.py | 13 | ||||
-rw-r--r-- | service/test/bitmask_libraries/soledad_test.py | 24 | ||||
-rw-r--r-- | service/test/test_tags.py | 8 |
7 files changed, 37 insertions, 37 deletions
diff --git a/service/test/__init__.py b/service/test/__init__.py index 8b137891..e69de29b 100644 --- a/service/test/__init__.py +++ b/service/test/__init__.py @@ -1 +0,0 @@ - diff --git a/service/test/adapter/test_helper.py b/service/test/adapter/test_helper.py index 7b935e7f..3731dfe8 100644 --- a/service/test/adapter/test_helper.py +++ b/service/test/adapter/test_helper.py @@ -9,9 +9,10 @@ LEAP_FLAGS = ['\\Seen', '\\Recent', 'List'] + def leap_mail(uid=0, extra_flags=[], headers={'date': str(datetime.now())}): - flags = LEAP_FLAGS + extra_flags - return Mock(getUID=Mock(return_value=uid), - getFlags=Mock(return_value=flags), - bdoc=Mock(content={'raw': 'test'}), - hdoc=Mock(content={'headers': headers})) + flags = LEAP_FLAGS + extra_flags + return Mock(getUID=Mock(return_value=uid), + getFlags=Mock(return_value=flags), + bdoc=Mock(content={'raw': 'test'}), + hdoc=Mock(content={'headers': headers})) diff --git a/service/test/bitmask_libraries/leap_srp_test.py b/service/test/bitmask_libraries/leap_srp_test.py index f02344f3..b1c05c92 100644 --- a/service/test/bitmask_libraries/leap_srp_test.py +++ b/service/test/bitmask_libraries/leap_srp_test.py @@ -9,22 +9,21 @@ import srp from app.bitmask_libraries.leap_srp import LeapSecureRemotePassword, LeapAuthException - - -(salt_bytes, verification_key_bytes) = srp.create_salted_verification_key('username', 'password', hash_alg=srp.SHA256, ng_type=srp.NG_1024) +(salt_bytes, verification_key_bytes) = srp.create_salted_verification_key('username', 'password', hash_alg=srp.SHA256, ng_type=srp.NG_1024) verifier = None @all_requests def not_found_mock(url, request): return {'status_code': 404, - 'content': 'foobar'} + 'content': 'foobar'} @all_requests def timeout_mock(url, request): raise Timeout() + @urlmatch(netloc=r'(.*\.)?leap\.local$') def srp_login_server_simulator_mock(url, request): global verifier diff --git a/service/test/bitmask_libraries/nicknym_test.py b/service/test/bitmask_libraries/nicknym_test.py index 17a87883..6e696e95 100644 --- a/service/test/bitmask_libraries/nicknym_test.py +++ b/service/test/bitmask_libraries/nicknym_test.py @@ -8,12 +8,12 @@ from abstract_leap_test import AbstractLeapTest class NickNymTest(AbstractLeapTest): @patch('app.bitmask_libraries.nicknym.KeyManager.__init__', return_value=None) def test_that_keymanager_is_created(self, init_mock): - #given + # given - #when + # when NickNym(self.provider, self.config, self.soledad_session, self.srp_session) - #then + # then init_mock.assert_called_with('test_user@some-server.test', 'https://nicknym.some-server.test:6425/', self.soledad, self.token, '/some/path/to/ca_cert', 'https://api.some-server.test:4430', '1', self.uuid, @@ -21,12 +21,12 @@ class NickNymTest(AbstractLeapTest): @patch('app.bitmask_libraries.nicknym.KeyManager') def test_gen_key(self, keymanager_mock): - #given + # given keyman = keymanager_mock.return_value keyman.get_key.side_effect = KeyNotFound nicknym = NickNym(self.provider, self.config, self.soledad_session, self.srp_session) - #when/then + # when/then nicknym.generate_openpgp_key() keyman.get_key.assert_called_with('test_user@some-server.test', openpgp.OpenPGPKey, fetch_remote=False, private=True) diff --git a/service/test/bitmask_libraries/provider_test.py b/service/test/bitmask_libraries/provider_test.py index 16abbd0d..7aa37db9 100644 --- a/service/test/bitmask_libraries/provider_test.py +++ b/service/test/bitmask_libraries/provider_test.py @@ -13,6 +13,7 @@ def not_found_mock(url, request): return {'status_code': 404, 'content': 'foobar'} + @urlmatch(netloc=r'(.*\.)?some-provider\.test$', path='/provider.json') def provider_json_mock(url, request): return provider_json_response("SHA256: 06e2300bdbc118c290eda0dc977c24080718f4eeca68c8b0ad431872a2baa22d") @@ -50,18 +51,18 @@ def soledad_json_mock(url, request): "content": json.dumps(content) } + @urlmatch(netloc=r'api\.some-provider\.test:4430$', path='/1/config/smtp-service.json') def smtp_json_mock(url, request): content = { "hosts": { "leap-mx": { - "hostname": "mx.some-provider.test", - "ip_address": "0.0.0.0", - "port": 465 - } - }, - "locations": { + "hostname": "mx.some-provider.test", + "ip_address": "0.0.0.0", + "port": 465 + } }, + "locations": {}, "serial": 1, "version": 1 } diff --git a/service/test/bitmask_libraries/soledad_test.py b/service/test/bitmask_libraries/soledad_test.py index 1c1c105e..0d865291 100644 --- a/service/test/bitmask_libraries/soledad_test.py +++ b/service/test/bitmask_libraries/soledad_test.py @@ -7,7 +7,7 @@ from abstract_leap_test import AbstractLeapTest class SoledadSessionTest(AbstractLeapTest): def setUp(self): - #given + # given self.provider.fetch_soledad_json.return_value = {'hosts': { 'couch1': { 'hostname': 'couch1.some-server.test', @@ -18,37 +18,37 @@ class SoledadSessionTest(AbstractLeapTest): @patch('app.bitmask_libraries.soledad.Soledad.__init__') def test_that_soledad_is_created_with_required_params(self, soledad_mock, init_mock): - #when + # when SoledadSession(self.provider, 'any-passphrase', self.srp_session) - #then + # then init_mock.assert_called_with(self.uuid, 'any-passphrase', '%s/soledad/%s.secret' % (self.leap_home, self.uuid), - '%s/soledad/%s.db' % (self.leap_home, self.uuid), - 'https://couch1.some-server.test:1234/user-%s' % self.uuid, - '/some/path/to/ca_cert', self.token) + '%s/soledad/%s.db' % (self.leap_home, self.uuid), + 'https://couch1.some-server.test:1234/user-%s' % self.uuid, + '/some/path/to/ca_cert', self.token) def test_that_sync_is_called(self, soledad_mock): instance = soledad_mock.return_value - instance.server_url = '/foo/bar' + instance.server_url = '/foo/bar' instance.need_sync.return_value = True soledad_session = SoledadSession(self.provider, 'any-passphrase', self.srp_session) - #when + # when soledad_session.sync() - #then + # then instance.need_sync.assert_called_with('/foo/bar') instance.sync.assert_called_with() def test_that_sync_not_called_if_not_needed(self, mock): instance = mock.return_value - instance.server_url = '/foo/bar' + instance.server_url = '/foo/bar' instance.need_sync.return_value = False soledad_session = SoledadSession(self.provider, 'any-passphrase', self.srp_session) - #when + # when soledad_session.sync() - #then + # then instance.need_sync.assert_called_with('/foo/bar') self.assertFalse(instance.sync.called) diff --git a/service/test/test_tags.py b/service/test/test_tags.py index 9c57ee07..52d2f069 100644 --- a/service/test/test_tags.py +++ b/service/test/test_tags.py @@ -14,16 +14,16 @@ class TagsTestCase(unittest.TestCase): def test_add_tag_to_collection(self): tag_collection = Tags() tag_collection.add('test') - self.assertEqual(len(tag_collection), len(Tags())+1) + self.assertEqual(len(tag_collection), len(Tags()) + 1) tag_collection.add('test2') - self.assertEqual(len(tag_collection), len(Tags())+2) + self.assertEqual(len(tag_collection), len(Tags()) + 2) def test_no_tag_duplication(self): tag_collection = Tags() tag_collection.add('test') - self.assertEqual(len(tag_collection), len(Tags())+1) + self.assertEqual(len(tag_collection), len(Tags()) + 1) tag_collection.add('test') - self.assertEqual(len(tag_collection), len(Tags())+1) + self.assertEqual(len(tag_collection), len(Tags()) + 1) def test_find_tag_on_collection(self): tag_collection = Tags() |