summaryrefslogtreecommitdiff
path: root/stacks/daemon/test_audio_dummy_backend.py
blob: c5ba31d707627045d67ae6fe3cfe4e41bc7a99bc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#!/usr/bin/env python3
"""Acoustic engine loopback + audio-dummy backend smoke tests."""
from __future__ import annotations

import sys
from pathlib import Path
from unittest.mock import MagicMock

ROOT = Path(__file__).resolve().parents[2]
sys.path.insert(0, str(ROOT / "stacks" / "daemon"))
sys.path.insert(0, str(ROOT / "stacks" / "crdop" / "lib"))

from acoustic_engine import AcousticEngine  # noqa: E402
from device_backends import AudioDummyBackend, DeviceBackendConfig, registry_tested  # noqa: E402


def test_loopback_decode() -> None:
    eng = AcousticEngine()
    rep = eng.loopback_self_test("TST-0", "QST")
    assert rep.symbols > 0
    assert rep.transitions > 0


def test_audio_dummy_backend_loopback_tx() -> None:
    cfg = DeviceBackendConfig(device_id="audio-dummy", backend_type="audio-dummy", audio_mode="loopback")
    rx: list[str] = []
    backend = AudioDummyBackend(cfg, on_rx=rx.append)
    assert backend.open()
    assert backend.attach_session("TST-0")
    ok, display = backend.transmit("TST-0", "QST", "hi", ax25_ui=True)
    assert ok
    assert "QST" in display
    backend.close()


def test_registry() -> None:
    assert registry_tested("audio-dummy") is True


def main() -> int:
    test_loopback_decode()
    test_audio_dummy_backend_loopback_tx()
    test_registry()
    print("OK: audio-dummy tests")
    return 0


if __name__ == "__main__":
    raise SystemExit(main())
git clone -b <branch> https://cgit.mode42.com/<repo>.git
git clone -b <branch> git://cgit.mode42.com/<repo>.git

info@mode42.com