Fakes for model-generic queries should assert the model
When a data-access function is refactored to take the ORM model as a parameter (e.g. get_job_with_artifacts(session, model, job_id) serving two parallel tables), route tests that monkeypatch it with a fake returning a canned object will still pass if a route passes the wrong model, because the fake ignores that argument. The bug in production is a confusing 404 from querying the wrong table. Make the fake take the model and assert requested is expected_model (defaulting to the common case). Check it by temporarily passing the wrong model in one route: the test should fail with the identity assertion. Also, when such a lookup moves from a dedicated function to a generic one, update which name the tests patch; routes that switch to a lighter lookup (no eager-loaded relations) need their tests to patch that function instead.