Cleanup tests

This commit is contained in:
zandercymatics 2024-08-08 10:32:27 -06:00
parent ac6561d879
commit 32630ad39a
No known key found for this signature in database
GPG key ID: FF4636ABEC9682B7

View file

@ -27,7 +27,8 @@ class GetSeniorOfficialJsonTest(TestCase):
def test_get_senior_official_json_authenticated_superuser(self):
"""Test that a superuser can fetch the senior official information."""
self.client.login(username="superuser", password="adminpass")
p = "adminpass"
self.client.login(username="superuser", password=p)
response = self.client.get(self.api_url, {"agency_name": "Test Agency"})
self.assertEqual(response.status_code, 200)
data = response.json()
@ -38,7 +39,8 @@ class GetSeniorOfficialJsonTest(TestCase):
def test_get_senior_official_json_authenticated_analyst(self):
"""Test that an analyst user can fetch the senior official's information."""
self.client.login(username="staffuser", password="userpass")
p = "userpass"
self.client.login(username="staffuser", password=p)
response = self.client.get(self.api_url, {"agency_name": "Test Agency"})
self.assertEqual(response.status_code, 200)
data = response.json()
@ -49,15 +51,15 @@ class GetSeniorOfficialJsonTest(TestCase):
def test_get_senior_official_json_unauthenticated(self):
"""Test that an unauthenticated user receives a 403 with an error message."""
self.client.login(username="testuser", password="password")
p = "password"
self.client.login(username="testuser", password=p)
response = self.client.get(self.api_url, {"agency_name": "Test Agency"})
self.assertEqual(response.status_code, 403)
data = response.json()
self.assertEqual(data["error"], "You do not have access to this resource")
self.assertEqual(response.status_code, 302)
def test_get_senior_official_json_not_found(self):
"""Test that a request for a non-existent agency returns a 404 with an error message."""
self.client.login(username="superuser", password="adminpass")
p = "adminpass"
self.client.login(username="superuser", password=p)
response = self.client.get(self.api_url, {"agency_name": "Non-Federal Agency"})
self.assertEqual(response.status_code, 404)
data = response.json()