Ban use of provider overriding in tests
Problem to solve
In #510 (closed) we had an incident where changes from !939 (merged) that made some resource handling asynchronous had the effect of switching all resource from the affected providers to be async as well. From the Dependency Injector docs:
If provider has any awaitable injections it switches into async mode. In async mode provider always returns awaitable
Thus, any code that was getting a resource from any of the affected providers would now need to handle coroutines. We missed some of these needed refactors, which caused runtime exceptions. Troublingly, our tests didn't catch the error. If we look at the tests for the affected endpoint, it relies on Provider overriding here for mocking, which completely bypasses the actual provider and can mask problems like the change from sync to async code that happened in the incident.
Proposal
Even though the Provider overriding documentation encourages you to use them for testing, its potential to hide bugs in tests is too high. Let's:
- Refactor our existing tests that rely on Provider overriding
- Create a linter that prevents its usage