Skip to content

Commit

Permalink
tests to check question loading on audit and RoR pages
Browse files Browse the repository at this point in the history
  • Loading branch information
struan committed May 1, 2024
1 parent fb38a7f commit 55b5366
Show file tree
Hide file tree
Showing 2 changed files with 61 additions and 0 deletions.
31 changes: 31 additions & 0 deletions crowdsourcer/tests/test_audit_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,37 @@ def test_no_access_if_wrong_session(self):
response = self.client.get(url)
self.assertEqual(response.status_code, 200)

def test_questions(self):
url = reverse("authority_audit", args=("Aberdeenshire Council", "Transport"))
response = self.client.get(url)
self.assertEqual(response.status_code, 200)

self.assertRegex(response.content, rb"vehicle fleet")
self.assertNotRegex(response.content, rb"Second Session")

def test_questions_alt_session(self):
u = User.objects.get(username="other_marker")
rt = ResponseType.objects.get(type="Audit")

a = Assigned.objects.get(user=u)
a.response_type = rt
a.save()

u.marker.response_type = rt
u.marker.save()

self.client.force_login(u)

url = reverse(
"session_urls:authority_audit",
args=("Second Session", "Aberdeenshire Council", "Transport"),
)
response = self.client.get(url)
self.assertEqual(response.status_code, 200)

self.assertRegex(response.content, rb"Second Session")
self.assertNotRegex(response.content, rb"vehicle fleet")

def test_save(self):
url = reverse("authority_audit", args=("Aberdeenshire Council", "Transport"))
response = self.client.get(url)
Expand Down
30 changes: 30 additions & 0 deletions crowdsourcer/tests/test_right_of_reply_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -352,6 +352,36 @@ def test_display_no_answer(self):
content = response.content
self.assertRegex(content, rb"<div[^>]*>[\s\n]*<p>\(none\)</p>[\s\n]*</div>")

def test_questions(self):
url = reverse("authority_ror", args=("Aberdeenshire Council", "Transport"))
response = self.client.get(url)
self.assertEqual(response.status_code, 200)

self.assertRegex(response.content, rb"vehicle fleet")
self.assertNotRegex(response.content, rb"Second Session")

def test_questions_alt_session(self):
u = User.objects.get(username="other_marker")
rt = ResponseType.objects.get(type="Right of Reply")

Assigned.objects.filter(user=u).delete()

u.marker.response_type = rt
u.marker.authority = PublicAuthority.objects.get(name="Aberdeenshire Council")
u.marker.save()

self.client.force_login(u)

url = reverse(
"session_urls:authority_ror",
args=("Second Session", "Aberdeenshire Council", "Transport"),
)
response = self.client.get(url)
self.assertEqual(response.status_code, 200)

self.assertRegex(response.content, rb"Second Session")
self.assertNotRegex(response.content, rb"vehicle fleet")

def test_save(self):
url = reverse("authority_ror", args=("Aberdeenshire Council", "Transport"))
response = self.client.get(url)
Expand Down

0 comments on commit 55b5366

Please sign in to comment.