diff options
author | Folker Bernitt <fbernitt@thoughtworks.com> | 2015-07-16 09:55:52 +0200 |
---|---|---|
committer | Folker Bernitt <fbernitt@thoughtworks.com> | 2015-08-11 17:00:23 +0200 |
commit | 1ee61a27b1a11f6e60dfd34fb72d3c63f05e7e24 (patch) | |
tree | 69af9525bfb06be97ab8ea0c9139b57b742b160c /service/test/unit | |
parent | 6e407f47f44a641b0bb080297487f2d1a5b48c7f (diff) |
Fixed unit tests.
Diffstat (limited to 'service/test/unit')
-rw-r--r-- | service/test/unit/adapter/test_mail.py | 4 | ||||
-rw-r--r-- | service/test/unit/bitmask_libraries/test_nicknym.py | 2 | ||||
-rw-r--r-- | service/test/unit/maintenance/test_commands.py | 3 | ||||
-rw-r--r-- | service/test/unit/resources/test_keys_resources.py | 27 |
4 files changed, 27 insertions, 9 deletions
diff --git a/service/test/unit/adapter/test_mail.py b/service/test/unit/adapter/test_mail.py index 92b1e905..f73ef333 100644 --- a/service/test/unit/adapter/test_mail.py +++ b/service/test/unit/adapter/test_mail.py @@ -17,7 +17,7 @@ import unittest import pixelated.support.date -from pixelated.adapter.model.mail import PixelatedMail, InputMail +from pixelated.adapter.model.mail import PixelatedMail, InputMail, HEADERS_KEY from mockito import mock, unstub, when from test.support import test_helper import dateutil.parser as dateparser @@ -119,7 +119,7 @@ class TestPixelatedMail(unittest.TestCase): input_mail = InputMail() input_mail.headers = headers - self.assertEqual('me@pixelated.org', input_mail.get_for_save(1, 'SENT')[1][fields.HEADERS_KEY]['From']) + self.assertEqual('me@pixelated.org', input_mail.get_for_save(1, 'SENT')[1][HEADERS_KEY]['From']) def test_as_dict(self): headers = {'Subject': 'The subject', diff --git a/service/test/unit/bitmask_libraries/test_nicknym.py b/service/test/unit/bitmask_libraries/test_nicknym.py index ca3b348d..85fd171d 100644 --- a/service/test/unit/bitmask_libraries/test_nicknym.py +++ b/service/test/unit/bitmask_libraries/test_nicknym.py @@ -61,5 +61,5 @@ class NickNymTest(AbstractLeapTest): # when/then nicknym.generate_openpgp_key() - keyman.get_key.assert_called_with('test_user@some-server.test', openpgp.OpenPGPKey, fetch_remote=False, private=True) + keyman.get_key.assert_called_with('test_user@some-server.test', openpgp.OpenPGPKey) keyman.gen_key.assert_called_with(openpgp.OpenPGPKey) diff --git a/service/test/unit/maintenance/test_commands.py b/service/test/unit/maintenance/test_commands.py index 7279f7a6..4eb2e990 100644 --- a/service/test/unit/maintenance/test_commands.py +++ b/service/test/unit/maintenance/test_commands.py @@ -19,6 +19,7 @@ import email from pixelated.maintenance import delete_all_mails, load_mails from pixelated.bitmask_libraries.session import LeapSession from leap.mail.constants import MessageFlags +from leap.mail.imap.account import IMAPAccount from leap.soledad.client import Soledad from leap.soledad.common.document import SoledadDocument from mock import MagicMock @@ -31,7 +32,9 @@ class TestCommands(unittest.TestCase): def setUp(self): self.leap_session = MagicMock(spec=LeapSession) self.soledad = MagicMock(spec=Soledad) + self.account = MagicMock(spec=IMAPAccount) self.mailbox = MagicMock() + self.leap_session.account = self.account self.args = (self.leap_session, self.soledad) diff --git a/service/test/unit/resources/test_keys_resources.py b/service/test/unit/resources/test_keys_resources.py index be79424b..71a6415a 100644 --- a/service/test/unit/resources/test_keys_resources.py +++ b/service/test/unit/resources/test_keys_resources.py @@ -1,3 +1,5 @@ +import json +import ast from mockito import mock, when from leap.keymanager import OpenPGPKey, KeyNotFound from pixelated.resources.keys_resource import KeysResource @@ -32,13 +34,26 @@ class TestKeysResource(unittest.TestCase): d = self.web.get(request) + expected = { + "tags": ["keymanager-key"], + "fingerprint": '', + "private": False, + 'sign_used': False, + 'refreshed_at': 0, + "expiry_date": 0, + "address": 'some@key', + 'encr_used': False, + 'last_audited_at': 0, + 'key_data': '', + 'length': 0, + 'key_id': '', + 'validation': 'Weak_Chain', + 'type': 'OpenPGPKey', + } + def assert_response(_): - self.assertEquals('"{\\"tags\\": [\\"keymanager-key\\"], \\"fingerprint\\": null, ' - '\\"private\\": null, \\"expiry_date\\": null, \\"address\\": ' - '\\"some@key\\", \\"last_audited_at\\": null, \\"key_data\\": null, ' - '\\"length\\": null, \\"key_id\\": null, \\"validation\\": null, ' - '\\"type\\": \\"<class \'leap.keymanager.openpgp.OpenPGPKey\'>\\", ' - '\\"first_seen_at\\": null}"', request.written[0]) + actual = json.loads(ast.literal_eval(request.written[0])) + self.assertEquals(expected, actual) d.addCallback(assert_response) return d |