Skip to content

Commit a7d846f

Browse files
committed
test: unit test shows staff member cannot add EnrollmentFlow with agency
using the same `ModelForm` class that the `SortableEnrollmentFlowAdmin` will provide to the admin interface, this test shows that if a staff member tries to submit the form with a transit agency configured for the flow, then there will be errors about `eligibility_api_` fields to which the staff member doesn't even have edit access.
1 parent 7bc6687 commit a7d846f

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

Diff for: tests/pytest/core/admin/test_enrollment.py

+21
Original file line numberDiff line numberDiff line change
@@ -165,3 +165,24 @@ def test_has_add_permission(
165165
request = admin_user_request(user_type)
166166

167167
assert flow_admin_model.has_add_permission(request) == expected
168+
169+
@pytest.mark.parametrize("include_transit_agency", [True, False])
170+
def test_EnrollmentFlowForm_staff_member(
171+
self, admin_user_request, flow_admin_model, model_TransitAgency, include_transit_agency
172+
):
173+
request = admin_user_request()
174+
175+
# get the Form class that's used in the admin add view as the user would see it
176+
form_class = flow_admin_model.get_form(request)
177+
178+
request.POST = dict(
179+
system_name="testflow",
180+
supported_enrollment_methods=[models.EnrollmentMethods.DIGITAL, models.EnrollmentMethods.IN_PERSON],
181+
)
182+
183+
if include_transit_agency:
184+
request.POST.update({"transit_agency": model_TransitAgency.id})
185+
186+
form = form_class(request.POST)
187+
assert not form.errors
188+
assert form.is_valid()

0 commit comments

Comments
 (0)