Пример #1
0
    def test_sna_write_structured_field(self):
        # Act
        (command, structured_fields) = parse_outbound_message(
            bytes.fromhex('f3 00 07 01 01 02 03 04 00 00 02 05 06 07'))

        # Assert
        self.assertEqual(command, Command.WSF)

        self.assertEqual([field[0] for field in structured_fields], [1, 2])
Пример #2
0
    def test_sna_erase_write(self):
        # Act
        (command, wcc, orders) = parse_outbound_message(bytes.fromhex('f5 c3 11 4b f0 1d f8 c8 c5 d3 d3 d6 40 e6 d6 d9 d3 c4'))

        # Assert
        self.assertEqual(command, Command.EW)

        self.assertIsInstance(wcc, WCC)
        self.assertEqual(wcc.value, 0xc3)

        self.assertEqual([order[0] for order in orders], [Order.SBA, Order.SF, None])
Пример #3
0
 def test_nop(self):
     self.assertEqual(parse_outbound_message(bytes.fromhex('03')),
                      (Command.NOP, ))
Пример #4
0
 def test_sna_read_buffer(self):
     self.assertEqual(parse_outbound_message(bytes.fromhex('f2')),
                      (Command.RB, ))
Пример #5
0
 def test_unrecognized_command(self):
     with self.assertRaisesRegex(ValueError, 'Unrecognized command 0x99'):
         parse_outbound_message(bytes.fromhex('99'))
Пример #6
0
 def test_sna_all_unprotected(self):
     self.assertEqual(parse_outbound_message(bytes.fromhex('6f')),
                      (Command.EAU, ))
Пример #7
0
 def test_sna_read_modified_all(self):
     self.assertEqual(parse_outbound_message(bytes.fromhex('63')),
                      (Command.RMA, ))
Пример #8
0
 def test_read_modified(self):
     self.assertEqual(parse_outbound_message(bytes.fromhex('06')),
                      (Command.RM, ))
Пример #9
0
 def test_sna_write_structured_field(self):
     with self.assertRaises(NotImplementedError):
         parse_outbound_message(bytes.fromhex('f3'))
Пример #10
0
 def test_sna_erase_write_alternate(self):
     with self.assertRaises(NotImplementedError):
         parse_outbound_message(bytes.fromhex('7e'))