summaryrefslogtreecommitdiff
path: root/service/test/unit/bitmask_libraries
diff options
context:
space:
mode:
authorNavaL <mnandri@thoughtworks.com>2016-02-03 17:23:42 +0100
committerNavaL <mnandri@thoughtworks.com>2016-02-05 14:43:07 +0100
commite7f77052f0aba1b84febf0ab1382c9602bbf7f93 (patch)
tree5fd8dd1016cbb21ebd4572284ca84f24bd9ccfa1 /service/test/unit/bitmask_libraries
parent92f0e9887a216e0ec82355941655d3deebf2d422 (diff)
closing the services closes leap session, which stops background tasks, close soldedad and remove it from cache
Issue #586
Diffstat (limited to 'service/test/unit/bitmask_libraries')
-rw-r--r--service/test/unit/bitmask_libraries/test_session.py24
1 files changed, 23 insertions, 1 deletions
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()