From e7f77052f0aba1b84febf0ab1382c9602bbf7f93 Mon Sep 17 00:00:00 2001 From: NavaL Date: Wed, 3 Feb 2016 17:23:42 +0100 Subject: closing the services closes leap session, which stops background tasks, close soldedad and remove it from cache Issue #586 --- .../test/unit/bitmask_libraries/test_session.py | 24 +++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) (limited to 'service/test/unit/bitmask_libraries') diff --git a/service/test/unit/bitmask_libraries/test_session.py b/service/test/unit/bitmask_libraries/test_session.py index 6e0e6204..bb1f55ca 100644 --- a/service/test/unit/bitmask_libraries/test_session.py +++ b/service/test/unit/bitmask_libraries/test_session.py @@ -17,7 +17,7 @@ from mock import patch from mock import MagicMock -from pixelated.bitmask_libraries.session import LeapSession +from pixelated.bitmask_libraries.session import LeapSession, SessionCache from test_abstract_leap import AbstractLeapTest from leap.common.events.catalog import KEYMANAGER_FINISHED_KEY_GENERATION @@ -69,6 +69,28 @@ class SessionTest(AbstractLeapTest): unregister_mock.assert_called_once_with(KEYMANAGER_FINISHED_KEY_GENERATION, uid=email) + def test_close_stops_soledad(self): + email = 'someone@somedomain.tld' + self.provider.address_for.return_value = email + session = self._create_session() + + session.close() + self.soledad_session.close.assert_called_once_with() + + def test_close_removes_session_from_cache(self): + email = 'someone@somedomain.tld' + self.provider.address_for.return_value = email + session = self._create_session() + + key = SessionCache.session_key(self.provider, self.auth.username) + SessionCache.remember_session(key, session) + + self.assertEqual(session, SessionCache.lookup_session(key)) + + session.close() + + self.assertIsNone(SessionCache.lookup_session(key)) + @patch('pixelated.bitmask_libraries.session.register') def test_session_fresh_is_initially_false(self, _): session = self._create_session() -- cgit v1.2.3