2023-08-13 16:51:27 +01:00
|
|
|
import re
|
|
|
|
|
2023-08-07 15:39:45 +01:00
|
|
|
import pytest
|
|
|
|
|
|
|
|
import voicemeeterlib
|
|
|
|
from tests import data, vm
|
|
|
|
|
|
|
|
|
|
|
|
class TestErrors:
|
|
|
|
__test__ = True
|
|
|
|
|
|
|
|
def test_it_tests_an_unknown_kind(self):
|
|
|
|
with pytest.raises(
|
|
|
|
voicemeeterlib.error.VMError,
|
2023-08-09 16:37:10 +01:00
|
|
|
match="Unknown Voicemeeter kind 'unknown_kind'",
|
2023-08-07 15:39:45 +01:00
|
|
|
):
|
|
|
|
voicemeeterlib.api("unknown_kind")
|
|
|
|
|
|
|
|
def test_it_tests_an_unknown_parameter(self):
|
|
|
|
with pytest.raises(
|
|
|
|
voicemeeterlib.error.CAPIError,
|
2023-08-09 16:37:10 +01:00
|
|
|
match="VBVMR_SetParameterFloat returned -3",
|
2023-08-07 15:39:45 +01:00
|
|
|
) as exc_info:
|
|
|
|
vm.set("unknown.parameter", 1)
|
|
|
|
|
|
|
|
e = exc_info.value
|
|
|
|
assert e.code == -3
|
|
|
|
assert e.fn_name == "VBVMR_SetParameterFloat"
|
|
|
|
|
2023-08-09 16:37:10 +01:00
|
|
|
def test_it_tests_an_unknown_config_name(self):
|
2023-08-07 15:39:45 +01:00
|
|
|
EXPECTED_MSG = (
|
2023-08-09 16:37:10 +01:00
|
|
|
"No config with name 'unknown' is loaded into memory",
|
2023-08-07 15:39:45 +01:00
|
|
|
f"Known configs: {list(vm.configs.keys())}",
|
|
|
|
)
|
|
|
|
|
2023-08-13 16:51:27 +01:00
|
|
|
with pytest.raises(
|
|
|
|
voicemeeterlib.error.VMError, match=re.escape("\n".join(EXPECTED_MSG))
|
|
|
|
):
|
|
|
|
vm.apply_config("unknown")
|
2023-08-09 16:37:10 +01:00
|
|
|
|
|
|
|
def test_it_tests_an_invalid_config_key(self):
|
|
|
|
CONFIG = {
|
|
|
|
"strip-0": {"A1": True, "B1": True, "gain": -6.0},
|
|
|
|
"bus-0": {"mute": True, "eq": {"on": True}},
|
|
|
|
"unknown-0": {"state": True},
|
|
|
|
"vban-out-1": {"name": "streamname"},
|
|
|
|
}
|
2023-08-10 16:24:30 +01:00
|
|
|
with pytest.raises(ValueError, match="invalid config key 'unknown-0'"):
|
2023-08-09 16:37:10 +01:00
|
|
|
vm.apply(CONFIG)
|