Group regression tests by domain (#215)
Move the flat backend/tests/*.py into domain subfolders so the suite mirrors the code's concerns: data/ climate, grading, scoring, grid, places, store web/ api, content, homepage, views notifications/ notify, digest, discord (+ dm/interactions/link) accounts/ api_accounts core/ metrics, singleton, dashboard conftest.py stays at the tests/ root, so its sys.path setup and shared fixtures still apply to every subfolder. The four tests that derive repo paths from __file__ get their depth bumped one level to match their new location. Pytest discovers the subfolders recursively; the CI command (python -m pytest backend/tests) is unchanged. Claude-Session: https://claude.ai/code/session_01XXxmNFy9cZ6Gh8Y9thZn62
This commit is contained in:
parent
581bdaca04
commit
21f7ef4d19
20 changed files with 5 additions and 5 deletions
|
|
@ -7,7 +7,7 @@ of polls (the non-leader workers) would cry DOWN for a perfectly healthy notifie
|
||||||
import importlib.util
|
import importlib.util
|
||||||
import os
|
import os
|
||||||
|
|
||||||
REPO = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
|
REPO = os.path.dirname(os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))))
|
||||||
_spec = importlib.util.spec_from_file_location(
|
_spec = importlib.util.spec_from_file_location(
|
||||||
"dashboard", os.path.join(REPO, "scripts", "dashboard.py"))
|
"dashboard", os.path.join(REPO, "scripts", "dashboard.py"))
|
||||||
dashboard = importlib.util.module_from_spec(_spec)
|
dashboard = importlib.util.module_from_spec(_spec)
|
||||||
|
|
@ -374,7 +374,7 @@ def test_measure_conversion_constants_match_the_frontend():
|
||||||
# Same drift risk as the country list: two hand-maintained copies.
|
# Same drift risk as the country list: two hand-maintained copies.
|
||||||
import os
|
import os
|
||||||
import content
|
import content
|
||||||
units_js = os.path.join(os.path.dirname(os.path.dirname(os.path.abspath(__file__))),
|
units_js = os.path.join(os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))),
|
||||||
os.pardir, "frontend", "units.js")
|
os.pardir, "frontend", "units.js")
|
||||||
with open(units_js, encoding="utf-8") as f:
|
with open(units_js, encoding="utf-8") as f:
|
||||||
src = f.read()
|
src = f.read()
|
||||||
|
|
@ -413,7 +413,7 @@ def test_f_country_list_matches_the_frontend():
|
||||||
# what a first-time visitor should see.
|
# what a first-time visitor should see.
|
||||||
import os
|
import os
|
||||||
import content
|
import content
|
||||||
units_js = os.path.join(os.path.dirname(os.path.dirname(os.path.abspath(__file__))),
|
units_js = os.path.join(os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))),
|
||||||
os.pardir, "frontend", "units.js")
|
os.pardir, "frontend", "units.js")
|
||||||
with open(units_js, encoding="utf-8") as f:
|
with open(units_js, encoding="utf-8") as f:
|
||||||
src = f.read()
|
src = f.read()
|
||||||
|
|
@ -215,7 +215,7 @@ def test_homepage_brand_keeps_the_lockup_styling(client, no_feed):
|
||||||
assert 'class="site-name"' in html
|
assert 'class="site-name"' in html
|
||||||
assert "<h1 class=\"site-name\"" not in html # the hero owns the h1
|
assert "<h1 class=\"site-name\"" not in html # the hero owns the h1
|
||||||
|
|
||||||
css = (pathlib.Path(__file__).parents[2] / "frontend" / "style.css").read_text()
|
css = (pathlib.Path(__file__).parents[3] / "frontend" / "style.css").read_text()
|
||||||
lockup = css.split(".brand h1", 1)[1].split("}", 1)[0]
|
lockup = css.split(".brand h1", 1)[1].split("}", 1)[0]
|
||||||
assert ".brand .site-name" in lockup, (
|
assert ".brand .site-name" in lockup, (
|
||||||
"the .brand h1 lockup rule must also match .brand .site-name"
|
"the .brand h1 lockup rule must also match .brand .site-name"
|
||||||
|
|
@ -21,7 +21,7 @@ def test_views_and_migrate_import_without_the_web_stack():
|
||||||
"assert 'fastapi' not in sys.modules, 'views/migrate pulled in FastAPI'; "
|
"assert 'fastapi' not in sys.modules, 'views/migrate pulled in FastAPI'; "
|
||||||
"assert 'app' not in sys.modules, 'views/migrate imported the web app'; "
|
"assert 'app' not in sys.modules, 'views/migrate imported the web app'; "
|
||||||
"import places; assert places._load_started is False")
|
"import places; assert places._load_started is False")
|
||||||
backend = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
backend = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
|
||||||
subprocess.run([sys.executable, "-c", code], cwd=backend, check=True)
|
subprocess.run([sys.executable, "-c", code], cwd=backend, check=True)
|
||||||
|
|
||||||
|
|
||||||
Loading…
Reference in a new issue