SXXXXXXX_PyMsc/test_integration.py

69 lines
2.0 KiB
Python

#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""Test that message definitions work with GUI."""
def test_message_imports():
"""Test that all messages can be imported."""
from pymsc.core.message_definitions import (
msg_a1, msg_a2, msg_a3, msg_a4, msg_a5,
msg_b6, msg_b7, msg_b9, msg_b10
)
assert msg_a1 is not None
assert msg_a2 is not None
print("✓ All messages imported successfully")
def test_field_mappings():
"""Test that field mappings work."""
from pymsc.core.field_mappings import get_field_path
# Test A2 mappings (corrected for actual getter/setter names)
assert get_field_path('A2', 'stby') == 'rdr_mode_command.stby'
assert get_field_path('A2', 'range_scale') == 'param1.range_scale'
# Test A1 mappings (corrected)
assert get_field_path('A1', 'alt_block') == 'settings.altitude_block'
print("✓ Field mappings working correctly")
def test_legacy_api():
"""Test that legacy API (get_value_for_field) works."""
from pymsc.core.message_definitions import msg_a2
# Test reading a value
val = msg_a2.get_value_for_field('stby')
assert isinstance(val, (int, type(None)))
print(f"✓ Legacy API working (stby = {val})")
def test_command_registry():
"""Test that command registry can be imported."""
from pymsc.gui.command_registry import CHECKBOXES, COMBOBOXES, SPINBOXES
assert len(CHECKBOXES) > 0
assert len(COMBOBOXES) > 0
# Verify structure
checkbox = CHECKBOXES[0]
assert 'message' in checkbox
assert 'field' in checkbox
print(f"✓ Command registry loaded ({len(CHECKBOXES)} checkboxes, {len(COMBOBOXES)} comboboxes)")
if __name__ == '__main__':
print("\n" + "=" * 60)
print("Integration Test Suite")
print("=" * 60 + "\n")
test_message_imports()
test_field_mappings()
test_legacy_api()
test_command_registry()
print("\n" + "=" * 60)
print("All Tests Passed!")
print("=" * 60 + "\n")