/
/
1"""Unit tests for the AirPlay Receiver provider (deterministic AirPlay port)."""
2
3from music_assistant.providers.airplay_receiver import airplay_receiver_port
4
5
6def test_airplay_receiver_port_is_deterministic() -> None:
7 """The port derivation must be stable across processes/restarts (unlike ``hash()``)."""
8 # pinned expectations guard against accidental changes to the derivation:
9 # the AirPlay provider relies on reproducing these ports from config alone
10 assert airplay_receiver_port("airplay_receiver--test1234") == 7745
11 assert airplay_receiver_port("airplay_receiver--aabbccdd") == 7038
12
13
14def test_airplay_receiver_port_stays_in_expected_range() -> None:
15 """Derived ports stay within the 7000-7999 AirPlay range for any instance id."""
16 for index in range(50):
17 port = airplay_receiver_port(f"airplay_receiver--instance{index}")
18 assert 7000 <= port <= 7999
19