| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465 |
- 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_use_stable_mono_aux0_ports(self):
- input_command = loopback_command(
- "/usr/bin/pw-loopback",
- "rigforge.mod-host-input",
- "rigforge.mod-host-input",
- "rigforge.mod-host-input.capture",
- "AUX0",
- 2.666666,
- )
- output_command = loopback_command(
- "/usr/bin/pw-loopback",
- "rigforge.mod-host-output",
- "rigforge.mod-host-output.playback",
- "rigforge.mod-host-output",
- "AUX0",
- 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[8], "2.66667")
- self.assertIn("[AUX0]", command)
- self.assertIn("media.class=Audio/Sink", command[10])
- self.assertIn("media.class=Audio/Source", command[12])
- 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()
|