From 21f7ef4d19f953c660e78d405b89e71d46a2f1ee Mon Sep 17 00:00:00 2001 From: Emi Griffith Date: Sun, 19 Jul 2026 21:50:01 -0700 Subject: [PATCH] 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 --- tests/{ => accounts}/test_api_accounts.py | 0 tests/{ => core}/test_dashboard.py | 2 +- tests/{ => core}/test_metrics.py | 0 tests/{ => core}/test_singleton.py | 0 tests/{ => data}/test_climate.py | 0 tests/{ => data}/test_grading.py | 0 tests/{ => data}/test_grid.py | 0 tests/{ => data}/test_places.py | 0 tests/{ => data}/test_scoring.py | 0 tests/{ => data}/test_store.py | 0 tests/{ => notifications}/test_digest.py | 0 tests/{ => notifications}/test_discord.py | 0 tests/{ => notifications}/test_discord_dm.py | 0 tests/{ => notifications}/test_discord_interactions.py | 0 tests/{ => notifications}/test_discord_link.py | 0 tests/{ => notifications}/test_notify.py | 0 tests/{ => web}/test_api.py | 0 tests/{ => web}/test_content.py | 4 ++-- tests/{ => web}/test_homepage.py | 2 +- tests/{ => web}/test_views.py | 2 +- 20 files changed, 5 insertions(+), 5 deletions(-) rename tests/{ => accounts}/test_api_accounts.py (100%) rename tests/{ => core}/test_dashboard.py (95%) rename tests/{ => core}/test_metrics.py (100%) rename tests/{ => core}/test_singleton.py (100%) rename tests/{ => data}/test_climate.py (100%) rename tests/{ => data}/test_grading.py (100%) rename tests/{ => data}/test_grid.py (100%) rename tests/{ => data}/test_places.py (100%) rename tests/{ => data}/test_scoring.py (100%) rename tests/{ => data}/test_store.py (100%) rename tests/{ => notifications}/test_digest.py (100%) rename tests/{ => notifications}/test_discord.py (100%) rename tests/{ => notifications}/test_discord_dm.py (100%) rename tests/{ => notifications}/test_discord_interactions.py (100%) rename tests/{ => notifications}/test_discord_link.py (100%) rename tests/{ => notifications}/test_notify.py (100%) rename tests/{ => web}/test_api.py (100%) rename tests/{ => web}/test_content.py (99%) rename tests/{ => web}/test_homepage.py (99%) rename tests/{ => web}/test_views.py (98%) diff --git a/tests/test_api_accounts.py b/tests/accounts/test_api_accounts.py similarity index 100% rename from tests/test_api_accounts.py rename to tests/accounts/test_api_accounts.py diff --git a/tests/test_dashboard.py b/tests/core/test_dashboard.py similarity index 95% rename from tests/test_dashboard.py rename to tests/core/test_dashboard.py index 7538a61..20192f8 100644 --- a/tests/test_dashboard.py +++ b/tests/core/test_dashboard.py @@ -7,7 +7,7 @@ of polls (the non-leader workers) would cry DOWN for a perfectly healthy notifie import importlib.util 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( "dashboard", os.path.join(REPO, "scripts", "dashboard.py")) dashboard = importlib.util.module_from_spec(_spec) diff --git a/tests/test_metrics.py b/tests/core/test_metrics.py similarity index 100% rename from tests/test_metrics.py rename to tests/core/test_metrics.py diff --git a/tests/test_singleton.py b/tests/core/test_singleton.py similarity index 100% rename from tests/test_singleton.py rename to tests/core/test_singleton.py diff --git a/tests/test_climate.py b/tests/data/test_climate.py similarity index 100% rename from tests/test_climate.py rename to tests/data/test_climate.py diff --git a/tests/test_grading.py b/tests/data/test_grading.py similarity index 100% rename from tests/test_grading.py rename to tests/data/test_grading.py diff --git a/tests/test_grid.py b/tests/data/test_grid.py similarity index 100% rename from tests/test_grid.py rename to tests/data/test_grid.py diff --git a/tests/test_places.py b/tests/data/test_places.py similarity index 100% rename from tests/test_places.py rename to tests/data/test_places.py diff --git a/tests/test_scoring.py b/tests/data/test_scoring.py similarity index 100% rename from tests/test_scoring.py rename to tests/data/test_scoring.py diff --git a/tests/test_store.py b/tests/data/test_store.py similarity index 100% rename from tests/test_store.py rename to tests/data/test_store.py diff --git a/tests/test_digest.py b/tests/notifications/test_digest.py similarity index 100% rename from tests/test_digest.py rename to tests/notifications/test_digest.py diff --git a/tests/test_discord.py b/tests/notifications/test_discord.py similarity index 100% rename from tests/test_discord.py rename to tests/notifications/test_discord.py diff --git a/tests/test_discord_dm.py b/tests/notifications/test_discord_dm.py similarity index 100% rename from tests/test_discord_dm.py rename to tests/notifications/test_discord_dm.py diff --git a/tests/test_discord_interactions.py b/tests/notifications/test_discord_interactions.py similarity index 100% rename from tests/test_discord_interactions.py rename to tests/notifications/test_discord_interactions.py diff --git a/tests/test_discord_link.py b/tests/notifications/test_discord_link.py similarity index 100% rename from tests/test_discord_link.py rename to tests/notifications/test_discord_link.py diff --git a/tests/test_notify.py b/tests/notifications/test_notify.py similarity index 100% rename from tests/test_notify.py rename to tests/notifications/test_notify.py diff --git a/tests/test_api.py b/tests/web/test_api.py similarity index 100% rename from tests/test_api.py rename to tests/web/test_api.py diff --git a/tests/test_content.py b/tests/web/test_content.py similarity index 99% rename from tests/test_content.py rename to tests/web/test_content.py index f0db506..f6b3db1 100644 --- a/tests/test_content.py +++ b/tests/web/test_content.py @@ -374,7 +374,7 @@ def test_measure_conversion_constants_match_the_frontend(): # Same drift risk as the country list: two hand-maintained copies. import os 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") with open(units_js, encoding="utf-8") as f: src = f.read() @@ -413,7 +413,7 @@ def test_f_country_list_matches_the_frontend(): # what a first-time visitor should see. import os 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") with open(units_js, encoding="utf-8") as f: src = f.read() diff --git a/tests/test_homepage.py b/tests/web/test_homepage.py similarity index 99% rename from tests/test_homepage.py rename to tests/web/test_homepage.py index dfe19de..ec76b61 100644 --- a/tests/test_homepage.py +++ b/tests/web/test_homepage.py @@ -215,7 +215,7 @@ def test_homepage_brand_keeps_the_lockup_styling(client, no_feed): assert 'class="site-name"' in html assert "