Aug 19 - Update test files

This commit is contained in:
2026-08-19 16:34:42 -04:00
parent a4a8d84801
commit 8b2582705d
2 changed files with 95 additions and 17 deletions
+33 -2
View File
@@ -343,8 +343,39 @@ def test_inspector_is_not_offered_schedule_creation(client):
assert 'Create First Schedule' not in body
def test_customers_are_still_barred(client):
def test_customer_directors_may_reach_the_schedule_list(client):
"""A Customer Director plans work at their OWN facilities (Aug 2026).
They reach the list — scoped to their assignments, which for an
unassigned account like this one means an empty list, not a 403.
"""
tmpl, fac = _seed()
cust = _user('cara', 'customer')
_login(client, cust)
assert client.get('/inspection-schedules/?tab=completed').status_code == 403
assert client.get('/inspection-schedules/?tab=completed').status_code == 200
def test_customers_still_cannot_start_a_scheduled_inspection(client):
"""Planning is not performing — the boundary that replaced the old 403.
A Customer Director may create and edit a schedule; Start belongs to the
assigned inspector, and a customer is never one.
"""
from app import db
from app.models.inspection_schedule import InspectionSchedule
from app.utils.time_utils import now_eastern
tmpl, fac = _seed()
insp = _user('ivy', 'inspector')
sched = InspectionSchedule(
name='Weekly check', template_id=tmpl.id, facility_id=fac.id,
inspector_id=insp.id, frequency='weekly', mode='plan', active=True,
created_at=now_eastern(), next_run_at=now_eastern(),
)
db.session.add(sched)
db.session.commit()
sid = sched.id
cust = _user('cara', 'customer')
_login(client, cust)
assert client.get(f'/inspection-schedules/{sid}/start').status_code == 403