Skip to content

Commit d1c3f7e

Browse files
committed
fix test_get_location_penn_labs_member and test github actions gsr loading
1 parent 1992eba commit d1c3f7e

1 file changed

Lines changed: 16 additions & 6 deletions

File tree

backend/tests/gsr_booking/test_gsr_views.py

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -54,15 +54,23 @@ def setUp(self):
5454
@mock.patch("gsr_booking.views.WhartonGSRBooker.is_wharton", return_value=False)
5555
@mock.patch("gsr_booking.views.PennGroupsGSRBooker.is_seas", return_value=False)
5656
def test_get_location(self, mock_is_seas, mock_is_wharton):
57+
"""Test that regular users do not see Wharton or PennGroups GSRs"""
5758
response = self.client.get(reverse("locations"))
5859
res_json = json.loads(response.content)
60+
61+
# Regular users should NOT see Wharton or PennGroups GSRs
62+
# Verify that Huntsman (Wharton), Amy Gutmann Hall (PennGroups),
63+
# and Academic Research (Wharton) are not in the response
64+
gsr_ids = [entry["id"] for entry in res_json]
65+
self.assertNotIn(1, gsr_ids, "Regular users should not see Huntsman (Wharton GSR)")
66+
self.assertNotIn(
67+
2, gsr_ids, "Regular users should not see Amy Gutmann Hall (PennGroups GSR)"
68+
)
69+
self.assertNotIn(3, gsr_ids, "Regular users should not see Academic Research (Wharton GSR)")
70+
71+
# Verify all returned GSRs are LibCal
5972
for entry in res_json:
60-
if entry["id"] == 1:
61-
self.assertEquals(entry["name"], "Huntsman")
62-
if entry["id"] == 2:
63-
self.assertEquals(entry["name"], "Amy Gutmann Hall")
64-
if entry["id"] == 3:
65-
self.assertEquals(entry["name"], "Academic Research")
73+
self.assertEqual(entry["kind"], GSR.KIND_LIBCAL)
6674

6775
@mock.patch("gsr_booking.views.WhartonGSRBooker.is_wharton", return_value=False)
6876
@mock.patch("gsr_booking.views.PennGroupsGSRBooker.is_seas", return_value=False)
@@ -131,6 +139,8 @@ def test_get_location_wharton_seas_user(self, mock_is_seas, mock_is_wharton):
131139
def test_get_location_penn_labs_member(self):
132140
"""Test that Penn Labs members see all GSRs regardless of their individual status"""
133141
# Add user to Penn Labs group
142+
print("GSR count:", GSR.objects.count()) # Test that all GSRs are loaded
143+
134144
penn_labs_group = Group.objects.get(name="Penn Labs")
135145
GroupMembership.objects.create(
136146
user=self.user, group=penn_labs_group, accepted=True, type=GroupMembership.MEMBER

0 commit comments

Comments
 (0)