Exemplo n.º 1
0
 def test_property_name_split_on_null(self):
     instance = ParticipantPacket(
         self.binary_data(name=[
             name + '\x00Garbage Data' for name in self.expected_name
         ]))
     expected_result = self.expected_name
     self.assertListEqual(instance.name, expected_result)
Exemplo n.º 2
0
 def test_property_car_class_name(self):
     instance = ParticipantPacket(self.binary_data())
     expected_result = self.expected_car_class_name
     self.assertEqual(instance.car_class_name, expected_result)
Exemplo n.º 3
0
 def test_property_build_version_number(self):
     instance = ParticipantPacket(self.binary_data())
     expected_result = self.expected_build_version_number
     self.assertEqual(instance.build_version_number, expected_result)
Exemplo n.º 4
0
 def test_init_wrong_packet_type(self):
     with self.assertRaises(ValueError):
         ParticipantPacket(self.binary_data(packet_type=2))
Exemplo n.º 5
0
    def test_init_wrong_packet_length(self):
        test_binary_data = pack("H", 42)

        from struct import error
        with self.assertRaises(error):
            ParticipantPacket(test_binary_data)
Exemplo n.º 6
0
 def test_init(self):
     instance = ParticipantPacket(self.binary_data())
     expected_result = ParticipantPacket
     self.assertIsInstance(instance, expected_result)
Exemplo n.º 7
0
 def test_method_str(self):
     instance = ParticipantPacket(self.binary_data())
     expected_result = "ParticipantPacket"
     self.assertEqual(str(instance), expected_result)
Exemplo n.º 8
0
 def test_property_track_variation_split_on_null(self):
     instance = ParticipantPacket(
         self.binary_data(track_variation=self.expected_track_variation +
                          "\x00Garbage Data"))
     expected_result = self.expected_track_variation
     self.assertEqual(instance.track_variation, expected_result)
Exemplo n.º 9
0
 def test_property_track_variation(self):
     instance = ParticipantPacket(self.binary_data())
     expected_result = self.expected_track_variation
     self.assertEqual(instance.track_variation, expected_result)
Exemplo n.º 10
0
 def test_property_packet_type(self):
     instance = ParticipantPacket(self.binary_data())
     expected_result = self.expected_packet_type
     self.assertEqual(instance.packet_type, expected_result)
Exemplo n.º 11
0
 def test_property_data_hash(self):
     instance = ParticipantPacket(self.binary_data())
     expected_result = md5(self.binary_data()).hexdigest()
     self.assertEqual(instance.data_hash, expected_result)
Exemplo n.º 12
0
 def test_property_car_name_split_on_null(self):
     instance = ParticipantPacket(
         self.binary_data(car_class_name=self.expected_car_name +
                          "\x00Garbage Data"))
     expected_result = self.expected_car_name
     self.assertEqual(instance.car_name, expected_result)