| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970 |
- import sys
- import unittest
- from pathlib import Path
- from types import SimpleNamespace
- import yaml
- ROOT = Path(__file__).resolve().parents[1]
- sys.path.insert(0, str(ROOT / "scripts"))
- from run_mod_host_ports import assert_boundary_ports_absent, loopback_command
- class ModHostPipeWirePortTests(unittest.TestCase):
- @classmethod
- def setUpClass(cls):
- cls.state = yaml.safe_load(
- (ROOT / "config" / "desired-state.yaml").read_text(encoding="utf-8")
- )
- def test_input_and_output_loopbacks_expose_four_stable_mono_channels(self):
- input_command = loopback_command(
- "/usr/bin/pw-loopback",
- "rigforge.mod-host-input",
- "rigforge.mod-host-input",
- "rigforge.mod-host-input.capture",
- ["AUX0", "AUX1", "AUX2", "AUX3"],
- 2.666666,
- )
- output_command = loopback_command(
- "/usr/bin/pw-loopback",
- "rigforge.mod-host-output",
- "rigforge.mod-host-output.playback",
- "rigforge.mod-host-output",
- ["AUX0", "AUX1", "AUX2", "AUX3"],
- 2.666666,
- )
- self.assertIn("media.class=Audio/Sink", input_command[10])
- self.assertIn("rigforge.mod-host-input.capture", input_command[12])
- self.assertIn("rigforge.mod-host-output.playback", output_command[10])
- self.assertIn("rigforge.mod-host-output", output_command[12])
- for command in (input_command, output_command):
- self.assertIn("--channels", command)
- self.assertIn("--channel-map", command)
- self.assertIn("--latency", command)
- self.assertEqual(command[4], "4")
- self.assertEqual(command[8], "2.66667")
- self.assertIn("[AUX0,AUX1,AUX2,AUX3]", command)
- self.assertIn("media.class=Audio/Sink", command[10])
- self.assertIn("media.class=Audio/Source", command[12])
- self.assertEqual(
- self.state["deployment"]["mod_host_ports"]["channel_map"],
- ["AUX0", "AUX1", "AUX2", "AUX3"],
- )
- def test_runner_refuses_duplicate_boundary_names(self):
- def runner(command, **_kwargs):
- if command == ["pw-link", "-o"]:
- return SimpleNamespace(stdout="rigforge.mod-host-output:capture_AUX0\n")
- if command == ["pw-link", "-i"]:
- return SimpleNamespace(stdout="")
- self.fail(f"unexpected command: {command}")
- with self.assertRaisesRegex(RuntimeError, "already present"):
- assert_boundary_ports_absent(self.state, runner)
- if __name__ == "__main__":
- unittest.main()
|