Pass supervisor debug value to audio (#3752)

This commit is contained in:
Mike Degatano
2022-07-27 11:15:54 -04:00
committed by GitHub
parent 037e42e894
commit ebeff31bf6
2 changed files with 79 additions and 1 deletions

View File

@@ -0,0 +1,50 @@
"""Test audio plugin."""
from pathlib import Path
from unittest.mock import AsyncMock, Mock, patch
import pytest
from supervisor.const import LogLevel
from supervisor.coresys import CoreSys
from tests.plugins.test_dns import fixture_docker_interface # noqa: F401
@pytest.fixture(name="write_json")
async def fixture_write_json() -> Mock:
"""Mock json file writer."""
with patch("supervisor.plugins.audio.write_json_file") as write_json_file:
yield write_json_file
async def test_config_write(
coresys: CoreSys,
docker_interface: tuple[AsyncMock, AsyncMock],
write_json: Mock,
):
"""Test config write on audio start and restart."""
await coresys.plugins.audio.start()
docker_interface[0].assert_called_once()
docker_interface[1].assert_not_called()
write_json.assert_called_once_with(
Path("/data/audio/pulse_audio.json"),
{
"debug": False,
},
)
docker_interface[0].reset_mock()
write_json.reset_mock()
coresys.config.logging = LogLevel.DEBUG
await coresys.plugins.audio.restart()
docker_interface[0].assert_not_called()
docker_interface[1].assert_called_once()
write_json.assert_called_once_with(
Path("/data/audio/pulse_audio.json"),
{
"debug": True,
},
)