Unitize majority of test suite; avoid unnecessary calls to DB
@Datamance is already working on this.
Since Sep 3, 2020.
- Dominant language
- Python
- Stars
- 12
- Forks
- 21
- Avg merge
- 5d 19h
- Merged PRs (30d)
- 5
Description
TL;DR: Create proper distinction between unit and integration tests - don't pull from the DB any more than is necessary.
Narrative
As a developer, I want my tests to run as fast as possible (while remaining thorough). This facilitates a faster development cycle by saving precious minutes during the testing phase. If our tests are properly unitized (mocking out service dependencies), we can avoid the time-intensive churn of calling to the test database.
Acceptance Criteria
- All test files refactored
- All tests pass
Implementation Notes
One of the most notable antipatterns in our test suite is the "do-it-all" setUp function. As django.test.TestCase guarantees a clean database (running each test in a transaction and flushing afterward), setUp is run for literally each and every single test. While this guarantees determinism and frees us from having to worry about order of execution for individual test methods, it also means that we are generally using setUp incorrectly, loading all context required to run any of the test methods each time. This is clearly inefficient and will require some potentially tedious refactoring.
Test DB initialization will also be greatly helped by the Single App consolidation.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.