Skip to content

Commit

Permalink
additional error test
Browse files Browse the repository at this point in the history
  • Loading branch information
robamu committed Oct 16, 2023
1 parent 119e643 commit 22bb5fe
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
4 changes: 3 additions & 1 deletion tests/cfdp/pdus/test_file_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,9 @@ def test_max_file_seg_calculator_error(self):
file_seg_len = get_max_file_seg_len_for_max_packet_len_and_pdu_cfg(pdu_conf, 11)
self.assertEqual(file_seg_len, 0)
with self.assertRaises(ValueError):
file_seg_len = get_max_file_seg_len_for_max_packet_len_and_pdu_cfg(pdu_conf, 10)
file_seg_len = get_max_file_seg_len_for_max_packet_len_and_pdu_cfg(
pdu_conf, 10
)
fd_pdu = FileDataPdu(pdu_conf, FileDataParams(bytes(), 0))
with self.assertRaises(ValueError):
fd_pdu.get_max_file_seg_len_for_max_packet_len(10)
Expand Down
20 changes: 20 additions & 0 deletions tests/cfdp/pdus/test_nak_pdu.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,26 @@ def test_segment_req_for_packet_size_large_file_with_crc(self):
)
self.assertEqual(nak_pdu.get_max_seg_reqs_for_max_packet_size(90), 4)

def test_segment_req_for_packet_error(self):
pdu_conf = PduConfig.default()
nak_pdu = NakPdu(pdu_conf, start_of_scope=0, end_of_scope=0)
self.assertEqual(
0,
get_max_seg_reqs_for_max_packet_size_and_pdu_cfg(
max_packet_size=16, pdu_conf=PduConfig.default()
),
)
self.assertEqual(nak_pdu.get_max_seg_reqs_for_max_packet_size(16), 0)
with self.assertRaises(ValueError):
self.assertEqual(
0,
get_max_seg_reqs_for_max_packet_size_and_pdu_cfg(
max_packet_size=15, pdu_conf=PduConfig.default()
),
)
with self.assertRaises(ValueError):
self.assertEqual(nak_pdu.get_max_seg_reqs_for_max_packet_size(15), 0)

def test_packing_0(self):
nak_packed = self.nak_pdu.pack()
self.assertEqual(len(nak_packed), 19)
Expand Down

0 comments on commit 22bb5fe

Please sign in to comment.