def _test_config_format(self): self.udsclient.config['server_address_format'] = 32 self.udsclient.config['server_memorysize_format'] = 16 response = self.udsclient.write_memory_by_address(MemoryLocation(address=0x1234, memorysize=4), b'\x66\x77\x88\x99') alfid = AddressAndLengthFormatIdentifier(address_format = self.udsclient.config['server_address_format'], memorysize_format=self.udsclient.config['server_memorysize_format']) self.assertEqual(response.service_data.alfid_echo, alfid.get_byte_as_int()) self.assertEqual(response.service_data.memory_location_echo.address, 0x1234) self.assertEqual(response.service_data.memory_location_echo.memorysize, 4)
def test_ali_oob_values(self): # Out Of Bounds Value with self.assertRaises(ValueError): AddressAndLengthFormatIdentifier(memorysize_format=1, address_format=1) with self.assertRaises(ValueError): AddressAndLengthFormatIdentifier(memorysize_format=0, address_format=8) with self.assertRaises(ValueError): AddressAndLengthFormatIdentifier(memorysize_format=8, address_format=0) with self.assertRaises(ValueError): AddressAndLengthFormatIdentifier(memorysize_format=40, address_format=0) with self.assertRaises(ValueError): AddressAndLengthFormatIdentifier(memorysize_format=8, address_format=48) with self.assertRaises(ValueError): AddressAndLengthFormatIdentifier(memorysize_format='8', address_format=8) with self.assertRaises(ValueError): AddressAndLengthFormatIdentifier(memorysize_format=8, address_format='8')
def test_ali_1(self): alfid = AddressAndLengthFormatIdentifier(memorysize_format=8, address_format=8) self.assertEqual(alfid.get_byte(), b'\x11')
def test_str_repr(self): alfid = AddressAndLengthFormatIdentifier(memorysize_format=8, address_format=8) str(alfid) alfid.__repr__()