Summary
Address the two FIXMEs in backend/tests/conftest.py:
- Cell setup in
init_database (lines 81–84): Refactor for support of cells (currently commented-out; setup_cells is a separate fixture).
- Teardown cleanup (lines 96–104): Enable safe cleanup after tests; currently cannot call
db.drop_all() because power/TEROS models use sessions and tests run in a way that leaves the DB in use.
Current behavior
FIXME 1 — Cell setup (lines 81–84)
init_database creates tables with db.create_all() but does not create any cells (cell setup is commented out).
- A separate fixture
setup_cells (lines 118–129) creates cell_1 and cell_2 and commits. Tests that need cells use setup_cells; tests that need a clean DB use init_database.
- The FIXME asks to "refactor later for support of cells" (e.g. unify or document when to use which fixture).
FIXME 2 — Teardown (lines 96–104)
- After
yield test_client, the fixture does not run db.drop_all() (commented out).
- Reason noted in-code: power and TEROS models use sessions to update data; tests run asynchronously / in parallel, so dropping all tables would affect other tests still using the DB. The FIXME suggests we need to "wait or have the fixture generate all the values" (or otherwise make teardown safe).
Desired behavior
- Cell setup: Decide and implement a clear approach — e.g. optionally create default cells in
init_database, or document that tests requiring cells must use setup_cells, and remove/update the FIXME.
- Teardown: Introduce a teardown strategy that allows safe cleanup (e.g. session scoping, serialization of DB-using tests, or per-test DB state) so that
db.drop_all() (or equivalent) can be used where appropriate without breaking other tests.
Location
- File:
backend/tests/conftest.py
- FIXME 1: lines 81–84 (cell setup in
init_database)
- FIXME 2: lines 96–104 (teardown after
yield test_client)
Acceptance criteria
Summary
Address the two FIXMEs in
backend/tests/conftest.py:init_database(lines 81–84): Refactor for support of cells (currently commented-out;setup_cellsis a separate fixture).db.drop_all()because power/TEROS models use sessions and tests run in a way that leaves the DB in use.Current behavior
FIXME 1 — Cell setup (lines 81–84)
init_databasecreates tables withdb.create_all()but does not create any cells (cell setup is commented out).setup_cells(lines 118–129) createscell_1andcell_2and commits. Tests that need cells usesetup_cells; tests that need a clean DB useinit_database.FIXME 2 — Teardown (lines 96–104)
yield test_client, the fixture does not rundb.drop_all()(commented out).Desired behavior
init_database, or document that tests requiring cells must usesetup_cells, and remove/update the FIXME.db.drop_all()(or equivalent) can be used where appropriate without breaking other tests.Location
backend/tests/conftest.pyinit_database)yield test_client)Acceptance criteria