feat: Refactor smoke tests to focus on standard named routes and improve route filtering

This commit is contained in:
Ross
2026-05-11 09:09:22 +01:00
parent 26a73d1d3b
commit 863d65b4b3
+75 -2
View File
@@ -32,6 +32,63 @@ SKIP_NAMES = {
"admin:index", # admin app has its own dedicated tests and redirects heavily.
}
SKIP_NAMESPACES = {
"admin",
"tinymce",
"cookies",
}
STANDARD_NAME_HINTS = {
"index",
"home",
"help",
"about",
"privacy",
"stats",
"list",
"detail",
"view",
"overview",
"profile",
"inbox",
"messages",
"people",
"server",
"logs",
"trainees",
"normals",
"categories",
"search_page",
}
NON_STANDARD_NAME_HINTS = {
"create",
"update",
"delete",
"remove",
"add",
"edit",
"toggle",
"submit",
"save",
"bulk",
"json",
"dicom",
"viewer",
"download",
"upload",
"anonymise",
"migrate",
"truncate",
"image_size",
"series",
"mark",
"review",
"sync",
"reset",
"api",
}
@dataclass(frozen=True)
class NamedRoute:
@@ -86,7 +143,23 @@ def _all_named_routes() -> list[NamedRoute]:
return sorted(unique_routes.values(), key=lambda route: (route.name, sorted(route.kwargs)))
def _is_standard_route(route_name: str) -> bool:
parts = route_name.split(":")
namespace = parts[0] if len(parts) > 1 else ""
leaf_name = parts[-1]
if namespace in SKIP_NAMESPACES:
return False
if route_name in SKIP_NAMES:
return False
if any(hint in leaf_name for hint in NON_STANDARD_NAME_HINTS):
return False
return any(hint in leaf_name for hint in STANDARD_NAME_HINTS)
ALL_NAMED_ROUTES = _all_named_routes()
STANDARD_NAMED_ROUTES = [route for route in ALL_NAMED_ROUTES if _is_standard_route(route.name)]
@pytest.fixture
@@ -104,7 +177,7 @@ def smoke_client(db) -> Client:
@pytest.mark.django_db
@pytest.mark.parametrize("route", ALL_NAMED_ROUTES, ids=lambda route: route.name)
@pytest.mark.parametrize("route", STANDARD_NAMED_ROUTES, ids=lambda route: route.name)
def test_named_view_routes_do_not_return_server_errors(smoke_client: Client, route: NamedRoute):
if route.name in SKIP_NAMES:
pytest.skip("Route is intentionally excluded from this smoke suite.")
@@ -122,7 +195,7 @@ def test_named_view_routes_do_not_return_server_errors(smoke_client: Client, rou
@pytest.mark.django_db
@pytest.mark.parametrize("route", ALL_NAMED_ROUTES, ids=lambda route: route.name)
@pytest.mark.parametrize("route", STANDARD_NAMED_ROUTES, ids=lambda route: route.name)
def test_named_view_routes_anonymous_do_not_return_server_errors(route: NamedRoute):
if route.name in SKIP_NAMES:
pytest.skip("Route is intentionally excluded from this smoke suite.")