def test_get_saved_session_returns_session_after_successful_call_to_get_session( self, session_factory, token_provider): storage_session_manager = StorageSessionManager(session_factory) token_provider.get_login_info.return_value = {"serverUrl": "TEST-URI"} storage_session_manager.get_storage_session(token_provider) assert storage_session_manager.get_saved_session_for_url( "TEST-URI") is not None
def test_get_storage_session_calls_get_saved_session_for_url_if_session_already_created( self, session_factory, token_provider, mocker): storage_session_manager = StorageSessionManager(session_factory) storage_session_manager.create_storage_session = mocker.MagicMock() storage_session_manager.get_storage_session(token_provider) assert storage_session_manager.create_storage_session.call_count == 1 storage_session_manager.get_saved_session_for_url = mocker.MagicMock() storage_session_manager.get_storage_session(token_provider) storage_session_manager.get_storage_session(token_provider) assert storage_session_manager.get_saved_session_for_url.call_count == 2 # still only called once assert storage_session_manager.create_storage_session.call_count == 1
def test_get_storage_session_get_saved_session_initially_returns_none( self, session_factory): storage_session_manager = StorageSessionManager(session_factory) assert storage_session_manager.get_saved_session_for_url( "TEST-URI") is None