/
/
/
1"""Tests for protobuf encoding/decoding."""
2
3from __future__ import annotations
4
5from music_assistant.providers.yandex_station.protobuf import dumps, loads
6
7
8def test_roundtrip_simple() -> None:
9 """Test that encoding and decoding a simple dict is identity."""
10 data = {1: "radio_play", 2: '{"streamUrl": "http://example.com/stream.flac"}'}
11 encoded = dumps(data)
12 decoded = loads(encoded)
13 assert decoded[1] == b"radio_play"
14 val = decoded[2]
15 assert isinstance(val, (bytes, bytearray, memoryview))
16 assert b"streamUrl" in bytes(val)
17
18
19def test_dumps_produces_bytes() -> None:
20 """Test that dumps returns bytes."""
21 result = dumps({1: "test"})
22 assert isinstance(result, bytes)
23 assert len(result) > 0
24