Beispiel #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")
Beispiel #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")
Beispiel #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")
Beispiel #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")
Beispiel #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"
Beispiel #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")