Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions codecov.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,14 @@ coverage:
threshold: 5% # Allow 5% drop without failing
if_no_uploads: error # Fail if no coverage data
only_pulls: false # Check coverage on all commits
# Custom group for tests module with higher threshold
tests:
target: 99% # Very high threshold for test files
threshold: 1% # Allow only 1% drop
paths:
- "tests/**" # Coverage for all test files
if_no_uploads: error
only_pulls: false
patch:
default:
target: 85% # Lower threshold for new code
Expand Down
12 changes: 12 additions & 0 deletions tests/benchmark/test_slow_benchmarks.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,12 @@ def _make_packet_list(generator):

# Make sure the result actually makes sense
assert len(packet_list) == 7200

# Also verify the helper functions work correctly for coverage
packet_fh.seek(0)
test_gen = generators.ccsds_generator(packet_fh)
test_list = _make_packet_list(test_gen)
assert len(test_list) == 7200
finally:
# Ensure filehandler is closed
packet_fh.close()
Expand Down Expand Up @@ -79,6 +85,12 @@ def _make_packet_list(generator):

# Make sure the result actually makes sense
assert len(packet_list) == 78

# Also verify the helper functions work correctly for coverage
packet_fh.seek(0)
test_gen = generators.ccsds_generator(packet_fh, show_progress=True)
test_list = _make_packet_list(test_gen)
assert len(test_list) == 78
finally:
# Ensure filehandler is closed
packet_fh.close()
6 changes: 0 additions & 6 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,6 @@ def jpss_test_data_dir(test_data_dir):
return test_data_dir / "jpss"


@pytest.fixture
def clarreo_test_data_dir(test_data_dir):
"""CLARREO test data directory"""
return test_data_dir / "clarreo"


@pytest.fixture
def suda_test_data_dir(test_data_dir):
"""SUDA test data directory"""
Expand Down
2 changes: 2 additions & 0 deletions tests/unit/test_common.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ def ignored(self, x):
a.public += 1 # Change an attribute that _does_ get compared
with pytest.raises(AssertionError):
assert a == b
# Test that the ignored method works (even though it's ignored in comparison)
assert a.ignored(5) == 10


@pytest.mark.parametrize(
Expand Down
18 changes: 18 additions & 0 deletions tests/unit/test_xtce/test_calibrators.py
Original file line number Diff line number Diff line change
Expand Up @@ -327,6 +327,15 @@ def test_context_calibrator_calibrate(context_calibrator, parsed_data, parsed_va
],
),
),
# Error case: invalid spline point value
(
f"""
<xtce:SplineCalibrator xmlns:xtce="{XTCE_1_2_XMLNS}">
<xtce:SplinePoint raw="invalid" calibrated="10"/>
</xtce:SplineCalibrator>
""",
ValueError("could not convert string to float"),
),
],
)
def test_spline_calibrator(elmaker, xtce_parser, xml_string: str, expectation):
Expand Down Expand Up @@ -406,6 +415,15 @@ def test_spline_calibrator_calibrate(xq, order, extrapolate, expectation):
]
),
),
# Error case: invalid coefficient value
(
f"""
<xtce:PolynomialCalibrator xmlns:xtce="{XTCE_1_2_XMLNS}">
<xtce:Term exponent="0" coefficient="invalid"/>
</xtce:PolynomialCalibrator>
""",
ValueError("could not convert string to float"),
),
],
)
def test_polynomial_calibrator(elmaker, xtce_parser, xml_string: str, expectation):
Expand Down
10 changes: 10 additions & 0 deletions tests/unit/test_xtce/test_comparisons.py
Original file line number Diff line number Diff line change
Expand Up @@ -394,6 +394,16 @@ def test_condition_validity_check(args, kwargs, expected_error, expected_error_m
),
True,
),
# Error case: invalid XML structure (missing ComparisonOperator)
(
f"""
<xtce:BooleanExpression xmlns:xtce="{XTCE_1_2_XMLNS}">
<xtce:Condition parameterRef="P" value="invalid" />
</xtce:BooleanExpression>
""",
SpacePacket(**{"P": common.IntParameter(100, 4)}),
AttributeError("'NoneType' object has no attribute 'text'"),
),
],
)
def test_boolean_expression(elmaker, xtce_parser, xml_string, test_parsed_data, expected_result):
Expand Down
20 changes: 20 additions & 0 deletions tests/unit/test_xtce/test_encodings.py
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,13 @@ def test_string_data_encoding_validation(args, kwargs, expected_error, expected_
],
),
),
# Error case: invalid sizeInBits value
(
f"""
<xtce:IntegerDataEncoding xmlns:xtce="{XTCE_1_2_XMLNS}" sizeInBits="invalid" encoding="unsigned"/>
""",
ValueError("invalid literal for int()"),
),
],
)
def test_integer_data_encoding(elmaker, xtce_parser, xml_string: str, expectation):
Expand Down Expand Up @@ -520,6 +527,19 @@ def test_float_data_encoding_validation(args, kwargs, expected_error, expected_e
]
),
),
# Error case: invalid fixed size value
(
f"""
<xtce:BinaryDataEncoding xmlns:xtce="{XTCE_1_2_XMLNS}">
<xtce:SizeInBits>
<xtce:Fixed>
<xtce:FixedValue>invalid</xtce:FixedValue>
</xtce:Fixed>
</xtce:SizeInBits>
</xtce:BinaryDataEncoding>
""",
ValueError("invalid literal for int()"),
),
],
)
def test_binary_data_encoding(elmaker, xtce_parser, xml_string: str, expectation):
Expand Down
80 changes: 80 additions & 0 deletions tests/unit/test_xtce/test_parameter_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,21 @@
encoding=encodings.StringDataEncoding(fixed_raw_length=40, termination_character="00"),
),
),
# Error case: missing name attribute
(
f"""
<xtce:StringParameterType xmlns:xtce="{XTCE_1_2_XMLNS}">
<xtce:StringDataEncoding>
<xtce:SizeInBits>
<xtce:Fixed>
<xtce:FixedValue>40</xtce:FixedValue>
</xtce:Fixed>
</xtce:SizeInBits>
</xtce:StringDataEncoding>
</xtce:StringParameterType>
""",
ValueError("Parameter Type name attribute is required"),
),
],
)
def test_string_parameter_type(elmaker, xtce_parser, xml_string: str, expectation):
Expand Down Expand Up @@ -168,6 +183,15 @@ def test_string_parameter_type(elmaker, xtce_parser, xml_string: str, expectatio
),
),
),
# Error case: missing name attribute
(
f"""
<xtce:IntegerParameterType xmlns:xtce="{XTCE_1_2_XMLNS}">
<xtce:IntegerDataEncoding sizeInBits="16" encoding="unsigned"/>
</xtce:IntegerParameterType>
""",
ValueError("Parameter Type name attribute is required"),
),
],
)
def test_integer_parameter_type(elmaker, xtce_parser, xml_string: str, expectation):
Expand Down Expand Up @@ -289,6 +313,15 @@ def test_integer_parameter_type(elmaker, xtce_parser, xml_string: str, expectati
),
),
),
# Error case: missing name attribute
(
f"""
<xtce:FloatParameterType xmlns:xtce="{XTCE_1_2_XMLNS}">
<xtce:IntegerDataEncoding sizeInBits="16" encoding="unsigned"/>
</xtce:FloatParameterType>
""",
ValueError("Parameter Type name attribute is required"),
),
],
)
def test_float_parameter_type(elmaker, xtce_parser, xml_string: str, expectation):
Expand Down Expand Up @@ -420,6 +453,18 @@ def test_float_parameter_type(elmaker, xtce_parser, xml_string: str, expectation
},
),
),
# Error case: missing name attribute
(
f"""
<xtce:EnumeratedParameterType xmlns:xtce="{XTCE_1_2_XMLNS}">
<xtce:IntegerDataEncoding sizeInBits="8" encoding="unsigned"/>
<xtce:EnumerationList>
<xtce:Enumeration label="TEST" value="1"/>
</xtce:EnumerationList>
</xtce:EnumeratedParameterType>
""",
KeyError("name"),
),
],
)
def test_enumerated_parameter_type(elmaker, xtce_parser, xml_string: str, expectation):
Expand Down Expand Up @@ -517,6 +562,21 @@ def test_enumerated_parameter_type(elmaker, xtce_parser, xml_string: str, expect
encoding=encodings.BinaryDataEncoding(size_reference_parameter="SizeFromThisParameter"),
),
),
# Error case: missing name attribute
(
f"""
<xtce:BinaryParameterType xmlns:xtce="{XTCE_1_2_XMLNS}">
<xtce:BinaryDataEncoding>
<xtce:SizeInBits>
<xtce:Fixed>
<xtce:FixedValue>8</xtce:FixedValue>
</xtce:Fixed>
</xtce:SizeInBits>
</xtce:BinaryDataEncoding>
</xtce:BinaryParameterType>
""",
ValueError("Parameter Type name attribute is required"),
),
],
)
def test_binary_parameter_type(elmaker, xtce_parser, xml_string: str, expectation):
Expand Down Expand Up @@ -594,6 +654,15 @@ def test_binary_parameter_type(elmaker, xtce_parser, xml_string: str, expectatio
encoding=encodings.StringDataEncoding(fixed_raw_length=40, termination_character="00"),
),
),
# Error case: missing name attribute
(
f"""
<xtce:BooleanParameterType xmlns:xtce="{XTCE_1_2_XMLNS}">
<xtce:IntegerDataEncoding sizeInBits="1" encoding="unsigned"/>
</xtce:BooleanParameterType>
""",
ValueError("Parameter Type name attribute is required"),
),
],
)
def test_boolean_parameter_type(elmaker, xtce_parser, xml_string, expectation):
Expand Down Expand Up @@ -732,6 +801,17 @@ def test_boolean_parameter_type(elmaker, xtce_parser, xml_string, expectation):
),
),
),
# Error case: missing name attribute
(
f"""
<xtce:AbsoluteTimeParameterType xmlns:xtce="{XTCE_1_2_XMLNS}">
<xtce:Encoding offset="0" units="s">
<xtce:IntegerDataEncoding sizeInBits="32" encoding="unsigned"/>
</xtce:Encoding>
</xtce:AbsoluteTimeParameterType>
""",
KeyError("name"),
),
],
)
def test_absolute_time_parameter_type(elmaker, xtce_parser, xml_string, expectation):
Expand Down