def test_api_request_other_error(self, apimock): """Test api_request with an unknown API error""" with pytest.raises(DataGovApiError, match='CODE: message'): with apimock: api_request("http://api/error")
def test_api_request_key_invalid_error(self, apimock): """Test api_request with an invalid API key""" with pytest.raises(DataGovInvalidApiKeyError): with apimock: api_request("http://api/key")
def test_api_request_rate_limit_error(self, apimock): """Test api_request with an API rate limit exceeded error""" with pytest.raises(DataGovApiRateExceededError): with apimock: api_request("http://api/rate")
def test_api_request_parameter_error(self, apimock): """Test api_request with a parameter value error""" with pytest.raises(ValueError, match='something'): with apimock: api_request("http://api/param")
def test_api_request_ok(self, apimock): """Test api_request with a normal working response.""" with apimock: data = api_request("http://api/ok") assert data["key"] == "value"
def test_api_request_http_error(self, apimock): """Test api_request with a HTTP error code with no JSON""" with pytest.raises(HTTPError): with apimock: api_request("http://api/httperror")