You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
ADN-DMR-Peer-Server/tests/voice/test_broadcast_queue.py

54 lines
1.6 KiB

"""Voice broadcast queue (same-TG serialization)."""
from __future__ import annotations
from tests.harness.voice_helpers import make_voice_uc, voice_master_scenario
from adn_server.domain import bytes_3
def test_enqueue_broadcast_queues_second_same_tg() -> None:
scenario, master = voice_master_scenario()
uc = make_voice_uc(scenario, master)
targets = [{"sys_obj": master, "name": "MASTER-A", "slot": master.STATUS[2], "ts": 2}]
pkts = {1: [b"\x00" * 55], 2: [b"\x00" * 55]}
source = bytes_3(5000)
dst = bytes_3(91)
uc._broadcast_active_tgs.add("91")
uc._enqueue_broadcast("ann", targets, pkts, source, dst, 91, 0, "ANN-2")
assert len(uc._broadcast_queue) == 1
assert uc._scheduled == []
def test_broadcast_queue_drains_after_first_finishes() -> None:
scenario, master = voice_master_scenario()
uc = make_voice_uc(scenario, master)
targets = [{"sys_obj": master, "name": "MASTER-A", "slot": master.STATUS[2], "ts": 2}]
pkts = {1: [b"\x00" * 55], 2: [b"\x00" * 55]}
source = bytes_3(5000)
dst = bytes_3(91)
uc._broadcast_active_tgs.add("91")
uc._broadcast_queue.append(
{
"type": "ann",
"targets": targets,
"pkts_by_ts": pkts,
"source_id": source,
"dst_id": dst,
"tg": 91,
"num": 1,
"label": "ANN-2",
}
)
uc._broadcast_finished(91)
assert len(uc._scheduled) == 1
uc._scheduled.pop(0)[1][0]()
assert "91" in uc._broadcast_active_tgs
assert uc._broadcast_queue == []
assert len(uc._scheduled) == 1
assert uc._scheduled[0][0] == 0.5

Powered by TurnKey Linux.