mirror of
https://github.com/cisagov/manage.get.gov.git
synced 2025-05-17 18:09:25 +02:00
Modify tests for availability API to return false on error
This commit is contained in:
parent
9c7bbd31ec
commit
c75891ee90
3 changed files with 15 additions and 12 deletions
|
@ -108,8 +108,7 @@ class AvailableViewTest(MockEppLib):
|
|||
request.user = self.user
|
||||
response = available(request, domain=bad_string)
|
||||
self.assertFalse(json.loads(response.content)["available"])
|
||||
# domain set to raise error successfully raises error
|
||||
with self.assertRaises(RegistryError):
|
||||
# domain set to raise error returns false for availability
|
||||
error_domain_available = available(request, "errordomain.gov")
|
||||
self.assertFalse(json.loads(error_domain_available.content)["available"])
|
||||
|
||||
|
|
|
@ -89,6 +89,7 @@ def available(request, domain=""):
|
|||
{"available": False, "message": DOMAIN_API_MESSAGES["invalid"]}
|
||||
)
|
||||
# a domain is available if it is NOT in the list of current domains
|
||||
try:
|
||||
if check_domain_available(domain):
|
||||
return JsonResponse(
|
||||
{"available": True, "message": DOMAIN_API_MESSAGES["success"]}
|
||||
|
@ -97,3 +98,5 @@ def available(request, domain=""):
|
|||
return JsonResponse(
|
||||
{"available": False, "message": DOMAIN_API_MESSAGES["unavailable"]}
|
||||
)
|
||||
except:
|
||||
raise RegistryError("Registry cannot find domain availability.")
|
||||
|
|
|
@ -116,6 +116,7 @@ class TestURLAuth(TestCase):
|
|||
"/openid/callback",
|
||||
"/openid/callback/login/",
|
||||
"/openid/callback/logout/",
|
||||
"/api/v1/available"
|
||||
]
|
||||
|
||||
def assertURLIsProtectedByAuth(self, url):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue