diff options
Diffstat (limited to 'service/test')
-rw-r--r-- | service/test/unit/config/test_sessions.py | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/service/test/unit/config/test_sessions.py b/service/test/unit/config/test_sessions.py index a7e62c7a..ad4dd590 100644 --- a/service/test/unit/config/test_sessions.py +++ b/service/test/unit/config/test_sessions.py @@ -14,12 +14,12 @@ # You should have received a copy of the GNU Affero General Public License # along with Pixelated. If not, see <http://www.gnu.org/licenses/>. -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 @@ -43,6 +43,17 @@ class SessionTest(AbstractLeapTest): mail_fetcher_mock.startService.assert_called_once() @patch('pixelated.config.sessions.register') + @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') @defer.inlineCallbacks |