summaryrefslogtreecommitdiff
path: root/service/test/unit/resources
diff options
context:
space:
mode:
Diffstat (limited to 'service/test/unit/resources')
-rw-r--r--service/test/unit/resources/test_backup_account_resource.py10
-rw-r--r--service/test/unit/resources/test_base_resource.py8
2 files changed, 17 insertions, 1 deletions
diff --git a/service/test/unit/resources/test_backup_account_resource.py b/service/test/unit/resources/test_backup_account_resource.py
index 2b68dd1b..b8654203 100644
--- a/service/test/unit/resources/test_backup_account_resource.py
+++ b/service/test/unit/resources/test_backup_account_resource.py
@@ -50,12 +50,16 @@ class TestBackupAccountResource(unittest.TestCase):
mock_account_recovery.update_recovery_code.return_value = defer.succeed("Success")
request = DummyRequest(['/backup-account'])
request.method = 'POST'
+ request.content = MagicMock()
+ request.content.getvalue.return_value = '{"email": "test@test.com"}'
d = self.web.get(request)
def assert_update_recovery_code_called(_):
mock_account_recovery_init.assert_called_with(
self.resource._authenticator.bonafide_session,
- self.resource.soledad(request))
+ self.resource.soledad(request),
+ self.resource._service(request, '_leap_session').smtp_config,
+ self.resource.get_backup_email(request))
mock_account_recovery.update_recovery_code.assert_called()
d.addCallback(assert_update_recovery_code_called)
@@ -66,6 +70,8 @@ class TestBackupAccountResource(unittest.TestCase):
mock_update_recovery_code.return_value = defer.succeed("Success")
request = DummyRequest(['/backup-account'])
request.method = 'POST'
+ request.content = MagicMock()
+ request.content.getvalue.return_value = '{"email": "test@test.com"}'
d = self.web.get(request)
def assert_successful_response(_):
@@ -79,6 +85,8 @@ class TestBackupAccountResource(unittest.TestCase):
mock_update_recovery_code.return_value = defer.fail(Exception)
request = DummyRequest(['/backup-account'])
request.method = 'POST'
+ request.content = MagicMock()
+ request.content.getvalue.return_value = '{"email": "test@test.com"}'
d = self.web.get(request)
def assert_successful_response(_):
diff --git a/service/test/unit/resources/test_base_resource.py b/service/test/unit/resources/test_base_resource.py
index 35ae67c7..d7110917 100644
--- a/service/test/unit/resources/test_base_resource.py
+++ b/service/test/unit/resources/test_base_resource.py
@@ -25,3 +25,11 @@ class TestBaseResource(unittest.TestCase):
base_resource = BaseResource(mock_services_factory)
self.assertEqual(base_resource.soledad('request'), mock_services_factory.services()._leap_session.soledad)
+
+ def test_get_backup_email_from_request(self):
+ mock_services_factory = MagicMock()
+ request = MagicMock()
+ request.content.getvalue.return_value = '{"backupEmail": "test@test.com"}'
+ base_resource = BaseResource(mock_services_factory)
+
+ self.assertEqual(base_resource.get_backup_email(request), 'test@test.com')