Skip to content

Commit

Permalink
Update test_packets_sub9.py (#1100)
Browse files Browse the repository at this point in the history
* Update test_packets_sub9.py

* Update test_packets_sub9.py

* Reformatted sub9 usb_to_can test files with black

---------

Co-authored-by: Cameron Brown <[email protected]>
  • Loading branch information
MrinallU and cbrxyz authored Nov 10, 2023
1 parent b3ca7c4 commit 0f3d837
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions mil_common/drivers/mil_usb_to_can/test/test_packets_sub9.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@


@dataclass
class TestPacket(Packet, msg_id=0x47, subclass_id=0x44, payload_format="BHf"):
class TestPacket(Packet, msg_id=0x47, subclass_id=0x44, payload_format="?Hd"):
example_bool: bool
example_int: int
example_float: float
Expand All @@ -23,7 +23,7 @@ def test_simple_packet(self):
packet = TestPacket(False, 42, 3.14)
self.assertEqual(packet.msg_id, 0x47)
self.assertEqual(packet.subclass_id, 0x44)
self.assertEqual(packet.payload_format, "BHf")
self.assertEqual(packet.payload_format, "?Hd")
self.assertEqual(packet.example_bool, False)
self.assertEqual(packet.example_int, 42)
self.assertEqual(packet.example_float, 3.14)
Expand All @@ -36,6 +36,13 @@ def test_assembled_packet(self):
self.assertEqual(assembled[2], packet.msg_id)
self.assertEqual(assembled[3], packet.subclass_id)

def test_format(self):
packet = TestPacket(False, 42, 3.14)
self.assertEqual(
TestPacket.from_bytes(TestPacket.__bytes__(packet)),
packet,
)

def test_comparisons(self):
packet = TestPacket(False, 42, 3.14)
packet_two = TestPacket(False, 42, 3.14)
Expand Down

0 comments on commit 0f3d837

Please sign in to comment.