def test_get_storage_session_calls_create_session_only_once_for_given_token_provider( 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) storage_session_manager.get_storage_session(token_provider) assert storage_session_manager.create_storage_session.call_count == 1
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