/
/
/
1"""
2Fail when a provider or controller test lives as a flat file instead of its own folder.
3
4Provider tests must live in ``tests/providers/<name>/`` and controller tests in
5``tests/controllers/<name>/`` (mirroring ``music_assistant/providers/<name>/`` and
6``music_assistant/controllers/<name>/``) so CI can map a changed area to its tests.
7A flat ``tests/providers/test_<name>.py`` / ``tests/controllers/test_<name>.py`` breaks that.
8"""
9
10# ruff: noqa: T201
11
12from __future__ import annotations
13
14import sys
15from pathlib import Path
16
17# Areas whose tests must be organised in per-<name> folders, not flat files.
18FOLDERED_TEST_AREAS = ("tests/providers", "tests/controllers")
19
20
21def main() -> int:
22 """Return non-zero if any flat test file exists directly in a foldered area."""
23 flat = sorted(
24 str(path) for area in FOLDERED_TEST_AREAS for path in Path(area).glob("test_*.py")
25 )
26 if flat:
27 print("These tests must live in their own <name>/ folder, not as a flat file:")
28 for path in flat:
29 parent = Path(path).parent
30 name = Path(path).stem.removeprefix("test_")
31 print(f" {path} -> {parent}/{name}/{Path(path).name}")
32 return 1
33 return 0
34
35
36if __name__ == "__main__":
37 sys.exit(main())
38