Skip to content

test: add tests that run against a fake device - #241

Open
Solmath wants to merge 7 commits into
noahhusby:mainfrom
Solmath:feature/add-unit-tests
Open

test: add tests that run against a fake device#241
Solmath wants to merge 7 commits into
noahhusby:mainfrom
Solmath:feature/add-unit-tests

Conversation

@Solmath

@Solmath Solmath commented Aug 15, 2026

Copy link
Copy Markdown
Contributor

This adds tests for StreamMagicClient. They run against a fake device, so they never connect to a real streamer and never change settings on one.

Sorry for the size, most of it is JSON test data.

How it works

tests/fake_device.py is a small aiohttp server that answers the same websocket messages a real streamer does. tests/conftest.py starts it on localhost and connects a normal StreamMagicClient to it. The client uses its real connection code, only the device is fake.

Test data

The fake device answers with JSON captured from two real streamers, stored in tests/fixtures/<model>/. I replaced serial numbers, UDNs and track names with placeholders.

  • cxn100/ - API 1.9
  • 851n/ - API 1.8

The 851N files are a real capture, not a cut-down copy of the CXN100 one. It runs the older API and has no audio endpoints, which is what the tests for older devices rely on (test_older_api_device_connects, test_audio_features_rejected_when_unsupported).

What is covered

90 tests, split into connection, zone control, playback and audio.

CI

.github/workflows/tests.yml runs pytest on Python 3.11 to 3.14.

Happy to change anything here, especially the test data if you would rather have less of it.

@Solmath
Solmath marked this pull request as ready for review August 15, 2026 14:31
@Solmath
Solmath requested a review from noahhusby as a code owner August 15, 2026 14:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant