def test_get_storage_session_with_multiple_calls_returns_same_session( self, mock_tmp_auth): storage_session_manager = ConnectionManager() session1 = storage_session_manager.get_storage_connection( mock_tmp_auth) session2 = storage_session_manager.get_storage_connection( mock_tmp_auth) assert session1 is session2
def test_get_saved_session_returns_session_after_successful_call_to_get_session( self, mock_tmp_auth ): storage_session_manager = ConnectionManager() storage_session_manager.get_storage_connection(mock_tmp_auth) assert ( storage_session_manager.get_saved_connection_for_url("testhost.com") is not None )
def test_get_storage_session_raises_session_init_error_when_tmp_auth_raises_http_error( self, mock_tmp_auth, http_error, mocker ): error = http_error error.response = mocker.MagicMock(spec=Response) error.response.text = "" mock_tmp_auth.get_storage_url.side_effect = Py42HTTPError(error) storage_session_manager = ConnectionManager() with pytest.raises(Py42StorageSessionInitializationError): storage_session_manager.get_storage_connection(mock_tmp_auth)
def test_get_storage_session_calls_session_factory_with_token_provider( self, mock_tmp_auth ): storage_session_manager = ConnectionManager() connection = storage_session_manager.get_storage_connection(mock_tmp_auth) assert type(connection) == Connection
def test_get_storage_session_raises_session_init_error_when_tmp_auth_raises_http_error( self, mock_tmp_auth): mock_tmp_auth.get_storage_url.side_effect = Py42HTTPError(HTTPError()) storage_session_manager = ConnectionManager() with pytest.raises(Py42StorageSessionInitializationError): storage_session_manager.get_storage_connection(mock_tmp_auth)