/
/
/
1"""Basic tests for Yandex Smart Home plugin provider."""
2
3from __future__ import annotations
4
5import json
6from pathlib import Path
7
8import music_assistant.providers.yandex_smarthome.constants as _cmod
9from music_assistant.providers.yandex_smarthome.constants import (
10 CAPABILITY_ON_OFF,
11 CAPABILITY_RANGE,
12 CAPABILITY_TOGGLE,
13 CLOUD_SKILL_WEBHOOK_TEMPLATE,
14 CONF_CLOUD_INSTANCE_PASSWORD,
15 CONF_INSTANCE_NAME,
16 CONF_SKILL_TOKEN,
17 CONNECTION_TYPE_CLOUD_PLUS,
18 INSTANCE_MUTE,
19 INSTANCE_PAUSE,
20 INSTANCE_VOLUME,
21 YANDEX_DEVICE_TYPE_RECEIVER,
22 YANDEX_DIALOGS_CALLBACK_BASE,
23 YANDEX_DIALOGS_DEVELOPER_URL,
24 YANDEX_OAUTH_URL,
25)
26
27# Locate manifest.json relative to the provider module (works in both local and upstream layouts)
28_MANIFEST_PATH = Path(_cmod.__file__).parent / "manifest.json"
29
30
31def test_manifest_valid() -> None:
32 """Manifest should be valid JSON with required fields."""
33 data = json.loads(_MANIFEST_PATH.read_text())
34
35 assert data["type"] == "plugin"
36 assert data["domain"] == "yandex_smarthome"
37 assert data["name"] == "Yandex Smart Home"
38 assert data["stage"] == "alpha"
39 assert data["multi_instance"] is False
40 assert data["builtin"] is False
41 assert isinstance(data["requirements"], list)
42 assert "ya-passport-auth[ma]==1.7.0" in data["requirements"]
43
44
45def test_manifest_has_codeowners() -> None:
46 """Manifest should declare codeowners."""
47 data = json.loads(_MANIFEST_PATH.read_text())
48
49 assert "codeowners" in data
50 assert len(data["codeowners"]) > 0
51
52
53def test_constants_defined() -> None:
54 """Core constants should be importable and non-empty."""
55 assert CONF_INSTANCE_NAME
56 assert CONF_CLOUD_INSTANCE_PASSWORD
57 assert YANDEX_DEVICE_TYPE_RECEIVER
58
59
60def test_cloud_plus_constants() -> None:
61 """Cloud Plus constants should be importable and well-formed."""
62 assert CONNECTION_TYPE_CLOUD_PLUS == "cloud_plus"
63 assert CONF_SKILL_TOKEN == "skill_token"
64 assert "dialogs.yandex.net" in YANDEX_DIALOGS_CALLBACK_BASE
65 assert "dialogs.yandex.ru" in YANDEX_DIALOGS_DEVELOPER_URL
66 assert "oauth.yandex.ru" in YANDEX_OAUTH_URL
67 assert "yaha-cloud.ru" in CLOUD_SKILL_WEBHOOK_TEMPLATE
68
69
70def test_constants_capability_types() -> None:
71 """Yandex capability constants should be properly defined."""
72 assert "on_off" in CAPABILITY_ON_OFF
73 assert "range" in CAPABILITY_RANGE
74 assert "toggle" in CAPABILITY_TOGGLE
75 assert INSTANCE_VOLUME == "volume"
76 assert INSTANCE_MUTE == "mute"
77 assert INSTANCE_PAUSE == "pause"
78