Separated availability error tests into two

This commit is contained in:
Erin 2023-11-30 11:10:50 -08:00
parent b3145b96c7
commit a5e2e030c2
No known key found for this signature in database
GPG key ID: 1CAD275313C62460

View file

@ -100,19 +100,23 @@ class AvailableViewTest(MockEppLib):
response = available(request, domain="igorville")
self.assertTrue(json.loads(response.content)["available"])
def test_error_handling(self):
"""Calling with bad strings returns error (error verifying) or unavailable (invalid domain)."""
def test_bad_string_handling(self):
"""Calling with bad strings returns unavailable."""
bad_string = "blah!;"
request = self.factory.get(API_BASE_PATH + bad_string)
request.user = self.user
response = available(request, domain=bad_string)
self.assertFalse(json.loads(response.content)["available"])
def test_error_handling(self):
"""Error thrown while calling availabilityAPI returns error."""
request = self.factory.get(API_BASE_PATH + "errordomain.gov")
request.user = self.user
# domain set to raise error returns false for availability and error message
error_domain_response = available(request, domain="errordomain.gov")
self.assertFalse(json.loads(error_domain_response.content)["available"])
self.assertIn("Error finding domain availability", json.loads(error_domain_response.content)["message"])
class AvailableAPITest(MockEppLib):
"""Test that the API can be called as expected."""