def test_exists_http_error(self, requests_mocker, method): """ In case of an unexpected HTTP error, ``exists()`` should not silently catch it. """ api_data_set = APIDataSet(url=TEST_URL, method=method, params=TEST_PARAMS, headers=TEST_HEADERS) requests_mocker.register_uri( method, TEST_URL_WITH_PARAMS, headers=TEST_HEADERS, text="Nope, not found", status_code=requests.codes.FORBIDDEN, ) with pytest.raises(DataSetError, match="Failed to fetch data"): api_data_set.exists()
def test_exists_ok(self, requests_mocker, method): """ If the file actually exists and server responds 200, ``exists()`` should return True """ api_data_set = APIDataSet(url=TEST_URL, method=method, params=TEST_PARAMS, headers=TEST_HEADERS) requests_mocker.register_uri( method, TEST_URL_WITH_PARAMS, headers=TEST_HEADERS, text=TEST_TEXT_RESPONSE_DATA, ) assert api_data_set.exists()