Skip to content

Issues/47 support xtce unitset#258

Merged
medley56 merged 3 commits into
mainfrom
issues/47-support-xtce-unitset
Jun 9, 2026
Merged

Issues/47 support xtce unitset#258
medley56 merged 3 commits into
mainfrom
issues/47-support-xtce-unitset

Conversation

@blakedehaas

Copy link
Copy Markdown
Collaborator

Summary

Adds support for multiple <xtce:Unit> elements within a <xtce:UnitSet>.

Previously, only a single unit was supported. This change allows compound units to be
parsed and serialized in accordance with the XTCE specification.

Changes

  • Updated ParameterType.get_units to return:
    • str for a single unit
    • tuple[str, ...] for multiple units
  • Updated to_xml to correctly serialize multiple <Unit> elements
  • Updated type hints and docstrings for consistency

Testing

  • Added test cases for multiple <xtce:Unit> support in:
    • IntegerParameterType
    • FloatParameterType
    • BinaryParameterType
  • Verified round-trip XML parsing and serialization
  • All tests pass (448 total), no regressions observed

@blakedehaas blakedehaas self-assigned this May 28, 2026
@blakedehaas blakedehaas requested a review from medley56 as a code owner May 28, 2026 19:09
@codecov

codecov Bot commented May 28, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 80.00000% with 4 lines in your changes missing coverage. Please review.
✅ Project coverage is 94.80%. Comparing base (946497d) to head (e222883).

Files with missing lines Patch % Lines
space_packet_parser/xtce/parameter_types.py 80.00% 4 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #258      +/-   ##
==========================================
- Coverage   94.85%   94.80%   -0.05%     
==========================================
  Files          48       48              
  Lines        3885     3892       +7     
==========================================
+ Hits         3685     3690       +5     
- Misses        200      202       +2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@codecov

codecov Bot commented May 28, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 94.91%. Comparing base (946497d) to head (62fdc34).

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #258      +/-   ##
==========================================
+ Coverage   94.85%   94.91%   +0.06%     
==========================================
  Files          48       48              
  Lines        3885     3892       +7     
==========================================
+ Hits         3685     3694       +9     
+ Misses        200      198       -2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@medley56 medley56 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice. One test coverage request.

Comment thread space_packet_parser/xtce/parameter_types.py

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds support for parsing and serializing multiple <xtce:Unit> elements within a <xtce:UnitSet>, replacing the previous NotImplementedError path. ParameterType.get_units now returns str for a single unit, tuple[str, ...] for compound units, or None. Serialization in both the base ParameterType.to_xml and EnumeratedParameterType.to_xml handles the tuple case.

Changes:

  • get_units returns str | tuple[str, ...] | None instead of raising on multiple units.
  • to_xml (base and enumerated) serializes each element of a tuple as a separate <Unit> child.
  • Updated type hints and docstrings on ParameterType, StringParameterType, BinaryParameterType, BooleanParameterType, and EnumeratedParameterType.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
space_packet_parser/xtce/parameter_types.py Adds tuple-based compound unit support in parsing and serialization; widens unit parameter types and docstrings.
tests/unit/test_xtce/test_parameter_types.py Adds round-trip tests with multiple <xtce:Unit> entries for Integer, Float, and Binary parameter types.

Comment thread tests/unit/test_xtce/test_parameter_types.py
@blakedehaas blakedehaas requested a review from medley56 June 1, 2026 20:39
@medley56 medley56 merged commit 7d5110e into main Jun 9, 2026
21 checks passed
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.

3 participants