Skip to content

Commit a068b2b

Browse files
committed
Improve tests to test for 403's
1 parent 3cc4e7e commit a068b2b

1 file changed

Lines changed: 18 additions & 2 deletions

File tree

src/teams/tests/test_shift_views.py

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,22 @@ def test_team_shift_views(self) -> None:
208208
rows = soup.select("table#main_table > tbody > tr")
209209
self.assertEqual(len(rows), 10, "team shift list does not return 10 entries after delete")
210210

211+
# Test creating a shift as a member not a lead.
212+
self.client.force_login(self.users[1]) # Noc team member
213+
url = reverse(
214+
"teams:shift_create",
215+
kwargs={
216+
"team_slug": self.teams["noc"].slug,
217+
"camp_slug": self.camp.slug,
218+
},
219+
)
220+
response = self.client.get(url, follow=True)
221+
assert response.status_code == 200
222+
soup = BeautifulSoup(content, "html.parser")
223+
rows = soup.select("div.alert.alert-danger")
224+
matches = [s for s in rows if "No thanks" in str(s)]
225+
self.assertEqual(len(matches), 0, "team shift create authorization failed incorrect")
226+
211227
def test_team_shift_actions(self) -> None:
212228
"""Test the team shift actions."""
213229
self.client.force_login(self.users[4]) # Noc teamlead
@@ -362,7 +378,7 @@ def test_team_shift_actions(self) -> None:
362378
soup = BeautifulSoup(content, "html.parser")
363379
rows = soup.select("div.alert.alert-danger")
364380
matches = [s for s in rows if "No thanks" in str(s)]
365-
self.assertEqual(len(matches), 0, "team shift authorization failed")
381+
self.assertEqual(len(matches), 0, "team shift authorization failed incorrect")
366382
response = self.client.post(
367383
path=url,
368384
follow=True,
@@ -371,4 +387,4 @@ def test_team_shift_actions(self) -> None:
371387
soup = BeautifulSoup(content, "html.parser")
372388
rows = soup.select("div.alert.alert-danger")
373389
matches = [s for s in rows if "No thanks" in str(s)]
374-
self.assertEqual(len(matches), 0, "team shift authorization failed")
390+
self.assertEqual(len(matches), 0, "team shift authorization failed incorrect")

0 commit comments

Comments
 (0)