Skip to content

Commit

Permalink
added test for pcap bits FieldCapture
Browse files Browse the repository at this point in the history
  • Loading branch information
evalott100 committed Jul 11, 2024
1 parent fa3b730 commit 7c311c5
Showing 1 changed file with 42 additions and 0 deletions.
42 changes: 42 additions & 0 deletions tests/test_hdf.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,48 @@ def __init__(self):
stop_pipeline(pipeline)


def test_field_capture_pcap_bits():
pcap_bits_frame_data = FieldCapture(
name="PCAP.BITS",
type=np.dtype("uint32"),
capture="Value",
scale=None,
offset=None,
units=None,
)

assert pcap_bits_frame_data.is_pcap_bits
assert pcap_bits_frame_data.raw_mode_dataset_dtype is np.dtype("uint32")

some_other_frame_data = FieldCapture(
name="some_other_frame_data",
type=np.dtype("uint32"),
capture="Value",
scale=1.0,
offset=0.0,
units="",
)

assert not some_other_frame_data.is_pcap_bits
assert some_other_frame_data.raw_mode_dataset_dtype is np.dtype("float64")

malformed_frame_data = FieldCapture(
name="malformed_frame_data",
type=np.dtype("uint32"),
capture="Value",
scale=None,
offset=0.0,
units="",
)

assert not some_other_frame_data.is_pcap_bits
with pytest.raises(
ValueError,
match="If any of `scale`, `offset`, or `units` is set, all must be set",
):
assert malformed_frame_data.raw_mode_dataset_dtype is np.dtype("float64")


@pytest.mark.parametrize(
"capture_record_hdf_names,expected_names",
[
Expand Down

0 comments on commit 7c311c5

Please sign in to comment.