summaryrefslogtreecommitdiff
path: root/service/test/unit/config
diff options
context:
space:
mode:
authorTayane Fernandes <tayane.rmf@gmail.com>2017-01-12 17:56:00 -0200
committerTayane Fernandes <tayane.rmf@gmail.com>2017-01-12 17:56:00 -0200
commit6a4545a33cb62abf32bf46422759778a88f96097 (patch)
tree65bc462859d5b9b0240d4cd5e18045e7057666f1 /service/test/unit/config
parentd2aabc8c514cb520d968e8241ec15c93bae2a0fe (diff)
Re-raise the exception after closing the session
We were trying to setup services even after closing the session. We fixed it and added unit test. Related with: #815
Diffstat (limited to 'service/test/unit/config')
-rw-r--r--service/test/unit/config/test_sessions.py12
1 files changed, 12 insertions, 0 deletions
diff --git a/service/test/unit/config/test_sessions.py b/service/test/unit/config/test_sessions.py
index a7e62c7a..8ae66015 100644
--- a/service/test/unit/config/test_sessions.py
+++ b/service/test/unit/config/test_sessions.py
@@ -17,9 +17,11 @@
import os
from mock import patch
from mock import MagicMock
+from mockito import when
from twisted.internet import defer
from twisted.trial import unittest
from pixelated.config.sessions import LeapSession, SessionCache
+from pixelated.bitmask_libraries.keymanager import UploadKeyError
from test.unit.bitmask_libraries.test_abstract_leap import AbstractLeapTest
from leap.common.events.catalog import KEYMANAGER_FINISHED_KEY_GENERATION
@@ -42,6 +44,16 @@ class SessionTest(AbstractLeapTest):
yield session.first_required_sync()
mail_fetcher_mock.startService.assert_called_once()
+ @defer.inlineCallbacks
+ def test_upload_key_error_closes_the_session(self):
+ when(self.keymanager).generate_openpgp_key().thenRaise(UploadKeyError('Could not upload key'))
+ session = self._create_session()
+ session.close = MagicMock()
+
+ with self.assertRaises(UploadKeyError):
+ yield session.finish_bootstrap()
+ session.close.assert_called_once()
+
@patch('pixelated.config.sessions.register')
@patch('pixelated.config.sessions.unregister')
@patch('pixelated.config.sessions.Account')