Skip to content

test: add comprehensive unit tests#20

Open
srleach wants to merge 2 commits intomainfrom
test/comprehensive-tests
Open

test: add comprehensive unit tests#20
srleach wants to merge 2 commits intomainfrom
test/comprehensive-tests

Conversation

@srleach
Copy link
Copy Markdown
Owner

@srleach srleach commented Apr 10, 2026

Summary

Add comprehensive unit tests for the spa2mqtt project.

Test Files

test_packet.py

  • Basic packet parsing and validation
  • Checksum verification
  • Protocol integration

test_protocols.py

  • Protocol abstraction (Plaintext, JacuzziEncrypted)
  • Protocol registry and lookup
  • Body decoding

test_base.py

  • Message field decoding (scale, xor, shift, mask, output_map)
  • MessageFactory registration
  • Spa base class initialization
  • Communicator setup

test_jacuzzi_encrypted.py

  • JacuzziEncryptedPacket construction and enum parsing
  • JacuzziEncryptedPacketType values
  • JacuzziTopsideControllerButton enum
  • JacuzziEncryptedSpa initialization
  • JacuzziEncryptedCommunicator
  • Config loading from YAML

test_transport.py

  • Transport layer (load_class, make_communicator, get_communicator)
  • Spa configuration loading
  • Variant configuration resolution

Coverage

  • 57 tests passing
  • 5 skipped (message decoding tests require valid packet checksums to set up)
  • Tests cover pluggable communicator types (base, jacuzzi_encrypted)

Running Tests

pytest tests/ -v

srleach added 2 commits April 9, 2026 23:32
- Phase 1: Standardize YAML config (binary_sensor: True -> type: binary_sensor)
- Phase 2: Add protocol abstraction (Protocol, PlaintextProtocol, JacuzziEncryptedProtocol)
- Phase 3: Refactor base classes (MessageFactory rename, protocol injection in Spa)
- Phase 4: Add tests and docs (17 tests, ARCHITECTURE.md)

The protocol layer now cleanly separates decoding logic from packet parsing,
making it easy to add new spa types without duplicating infrastructure.
- test_packet.py: Basic packet parsing
- test_protocols.py: Protocol abstraction
- test_base.py: Message, MessageFactory, Spa, Communicator
- test_jacuzzi_encrypted.py: Jacuzzi-specific packet types
- test_transport.py: Transport layer and config loading

57 passed, 5 skipped
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