Example #1
0
 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")
Example #2
0
 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")
Example #3
0
 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")
Example #4
0
 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")
Example #5
0
 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"
Example #6
0
 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")