lookit / lookit/lookit-api

Unitize majority of test suite; avoid unnecessary calls to DB

Open
#564 0 comments 0 reactions 1 assignee View on GitHub

@Datamance is already working on this.

Since Sep 3, 2020.

Developer Scoping
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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.