/
/
/
1"""Tests for the advisory provider-scope check."""
2
3from scripts.check_provider_scope import classify, provider_name
4
5
6def test_provider_name_detects_package_and_tests() -> None:
7 """Provider package and provider test paths resolve to the provider name."""
8 assert provider_name("music_assistant/providers/spotify/__init__.py") == "spotify"
9 assert provider_name("tests/providers/spotify/test_spotify.py") == "spotify"
10 assert provider_name("music_assistant/helpers/audio.py") is None
11 assert provider_name("README.md") is None
12
13
14def test_single_provider_only_is_in_scope() -> None:
15 """A change confined to one provider (and its tests) reports no shared files."""
16 providers, shared = classify(
17 [
18 "music_assistant/providers/spotify/__init__.py",
19 "tests/providers/spotify/test_spotify.py",
20 ]
21 )
22 assert providers == {"spotify"}
23 assert shared == []
24
25
26def test_generated_artifacts_are_not_shared() -> None:
27 """Generated requirements/translations that accompany a provider change are ignored."""
28 providers, shared = classify(
29 [
30 "music_assistant/providers/spotify/manifest.json",
31 "requirements_all.txt",
32 "music_assistant/translations/en.json",
33 ]
34 )
35 assert providers == {"spotify"}
36 assert shared == []
37
38
39def test_shared_code_alongside_provider_is_reported() -> None:
40 """Editing shared server code in a provider PR surfaces those files."""
41 providers, shared = classify(
42 [
43 "music_assistant/providers/spotify/__init__.py",
44 "music_assistant/helpers/audio.py",
45 "tests/helpers/test_audio.py",
46 ]
47 )
48 assert providers == {"spotify"}
49 assert shared == ["music_assistant/helpers/audio.py", "tests/helpers/test_audio.py"]
50
51
52def test_no_provider_change_reports_nothing() -> None:
53 """A pure core change has no provider context, so nothing is reported as out-of-scope."""
54 providers, shared = classify(["music_assistant/helpers/audio.py"])
55 assert providers == set()
56 assert shared == ["music_assistant/helpers/audio.py"]
57