seeding expansion
also: replace energy output with energy output density
This commit is contained in:
48
tests/test_admin.py
Normal file
48
tests/test_admin.py
Normal file
@@ -0,0 +1,48 @@
|
||||
"""Tests for admin panel — clear_all, reseed, and additive reseed."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from physcom.seed.transport_example import load_transport_seed
|
||||
|
||||
|
||||
def test_clear_all_wipes_data(seeded_repo):
|
||||
"""clear_all() should remove all rows from every table."""
|
||||
repo = seeded_repo
|
||||
assert len(repo.list_entities()) > 0
|
||||
assert len(repo.list_domains()) > 0
|
||||
|
||||
repo.clear_all()
|
||||
|
||||
assert len(repo.list_entities()) == 0
|
||||
assert len(repo.list_domains()) == 0
|
||||
assert len(repo.list_dimensions()) == 0
|
||||
assert sum(repo.count_combinations_by_status().values()) == 0
|
||||
assert len(repo.list_pipeline_runs()) == 0
|
||||
|
||||
|
||||
def test_reseed_after_clear_restores_data(seeded_repo):
|
||||
"""Wipe then reseed should restore entity/domain counts."""
|
||||
repo = seeded_repo
|
||||
original_entities = len(repo.list_entities())
|
||||
original_domains = len(repo.list_domains())
|
||||
|
||||
repo.clear_all()
|
||||
assert len(repo.list_entities()) == 0
|
||||
|
||||
counts = load_transport_seed(repo)
|
||||
assert len(repo.list_entities()) == original_entities
|
||||
assert len(repo.list_domains()) == original_domains
|
||||
assert counts["platforms"] + counts["power_sources"] == original_entities
|
||||
|
||||
|
||||
def test_additive_reseed_no_duplicates(seeded_repo):
|
||||
"""Running reseed on an already-seeded DB should not create duplicates."""
|
||||
repo = seeded_repo
|
||||
before = len(repo.list_entities())
|
||||
|
||||
counts = load_transport_seed(repo)
|
||||
|
||||
assert len(repo.list_entities()) == before
|
||||
assert counts["platforms"] == 0
|
||||
assert counts["power_sources"] == 0
|
||||
assert counts["domains"] == 0
|
||||
Reference in New Issue
Block a user