|
2 | 2 | __author__ = "Elias Hawa"
|
3 | 3 |
|
4 | 4 | import pytest
|
5 |
| -from modules.telemetry.v1.data_block import PressureDB, TemperatureDB, LinearAccelerationDB, AngularVelocityDB |
| 5 | +from modules.telemetry.v1.data_block import ( |
| 6 | + PressureDB, |
| 7 | + TemperatureDB, |
| 8 | + LinearAccelerationDB, |
| 9 | + AngularVelocityDB, |
| 10 | + VoltageDB, |
| 11 | +) |
6 | 12 |
|
7 | 13 |
|
8 | 14 | @pytest.fixture
|
@@ -53,6 +59,19 @@ def angular_velocity_data_content() -> bytes:
|
53 | 59 | return b"\x00\x00\x00\x00\x06\x00\x0b\x00\xfd\xff\x00\x00"
|
54 | 60 |
|
55 | 61 |
|
| 62 | +@pytest.fixture |
| 63 | +# 9b0d00000200ee0c |
| 64 | +# DEBUG:modules.telemetry.telemetry_utils:VoltageDB -> time: 3483 ms, id: 2, voltage: 3310 mV |
| 65 | +def voltage_data_content() -> bytes: |
| 66 | + """ |
| 67 | + Returns a voltage sensor reading with the following attributes |
| 68 | + mission time: 3483 ms |
| 69 | + id: 2 |
| 70 | + voltage: 3310 mV |
| 71 | + """ |
| 72 | + return b"\x9b\x0d\x00\x00\x02\x00\xee\x0c" |
| 73 | + |
| 74 | + |
56 | 75 | def test_pressure_data_block(pressure_data_content: bytes) -> None:
|
57 | 76 | """Test that the pressure data block is parsed correctly."""
|
58 | 77 | pdb = PressureDB.from_bytes(pressure_data_content)
|
@@ -89,3 +108,12 @@ def test_angular_velocity_data_block(angular_velocity_data_content: bytes) -> No
|
89 | 108 | assert ang_vel.y_axis == 1.1
|
90 | 109 | assert ang_vel.z_axis == -0.3
|
91 | 110 | assert ang_vel.magnitude == 1.29
|
| 111 | + |
| 112 | + |
| 113 | +def test_voltage_data_block(voltage_data_content: bytes) -> None: |
| 114 | + """Test that the voltage data block is parsed correctly.""" |
| 115 | + vdb = VoltageDB.from_bytes(voltage_data_content) |
| 116 | + |
| 117 | + assert vdb.mission_time == 3483 |
| 118 | + assert vdb.id == 2 |
| 119 | + assert vdb.voltage == 3310 |
0 commit comments