warehouse
warehouse copied to clipboard
Tests: Over-mocking leads to errors surfaced in production
One example: https://github.com/pypi/warehouse/blob/ee2fe4154807fdf21823213939db33e60349ca8e/tests/unit/manage/views/test_oidc_publishers.py#L1190-L1348
These tests don't exercise the stack down to the data layer, leading to issues discovered in production, like #18879, as well as noted in related changes here: https://github.com/pypi/warehouse/pull/18862#pullrequestreview-3336254308
The action here is to start with the trusted publishing tests, and refactor to use less pretend, and lean into using db_request and factory fixtures as necessary, replacing pretend in favor of real objects, with factory fixtures whenever possible.