diff options
author | Anike Arni <aarni@thoughtworks.com> | 2017-03-17 11:18:39 -0300 |
---|---|---|
committer | Anike Arni <aarni@thoughtworks.com> | 2017-03-17 11:18:39 -0300 |
commit | 067db035910c8284d508401c34ca4cb5928c2b52 (patch) | |
tree | be4e94c21c6b6cf29a5d26b1debecbbf36b87fc2 /service/test/unit | |
parent | 3bc6901663c60e6b477477bd6e47e9f60fbb895b (diff) |
[#1012] Generates recovery code in soledad client
with @tayanefernandes
Diffstat (limited to 'service/test/unit')
-rw-r--r-- | service/test/unit/resources/test_backup_account_resource.py | 7 | ||||
-rw-r--r-- | service/test/unit/test_account_recovery.py | 9 |
2 files changed, 11 insertions, 5 deletions
diff --git a/service/test/unit/resources/test_backup_account_resource.py b/service/test/unit/resources/test_backup_account_resource.py index 2e676d9b..09520969 100644 --- a/service/test/unit/resources/test_backup_account_resource.py +++ b/service/test/unit/resources/test_backup_account_resource.py @@ -16,7 +16,8 @@ import os -from mock import MagicMock, patch +from mock import MagicMock, patch, ANY + from twisted.trial import unittest from twisted.web.test.requesthelper import DummyRequest from twisted.internet import defer @@ -48,12 +49,14 @@ class TestBackupAccountResource(unittest.TestCase): mock_account_recovery = MagicMock() mock_account_recovery_init.return_value = mock_account_recovery mock_account_recovery.update_recovery_code.return_value = defer.succeed("Success") + request = DummyRequest(['/backup-account']) request.method = 'POST' d = self.web.get(request) def assert_update_recovery_code_called(_): - mock_account_recovery_init.assert_called_with(self.resource._authenticator.bonafide_session) + mock_account_recovery_init.assert_called_with( + self.resource._authenticator.bonafide_session, ANY) mock_account_recovery.update_recovery_code.assert_called() d.addCallback(assert_update_recovery_code_called) diff --git a/service/test/unit/test_account_recovery.py b/service/test/unit/test_account_recovery.py index 026d161f..af14814a 100644 --- a/service/test/unit/test_account_recovery.py +++ b/service/test/unit/test_account_recovery.py @@ -26,8 +26,11 @@ class AccountRecoveryTest(unittest.TestCase): @inlineCallbacks def test_update_recovery_code(self): - mock_session = Mock() - account_recovery = AccountRecovery(mock_session) + generated_code = '4645a2f8997e5d0d' + mock_bonafide_session = Mock() + mock_soledad = Mock() + mock_soledad.create_recovery_code.return_value = generated_code + account_recovery = AccountRecovery(mock_bonafide_session, mock_soledad) yield account_recovery.update_recovery_code() - mock_session.update_recovery_code.assert_called_once_with('123') + mock_bonafide_session.update_recovery_code.assert_called_once_with(generated_code) |