Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def _test_request_transfer_exit_success(self):
response = self.udsclient.request_transfer_exit(data=b'\x12\x34\x56')
self.assertEqual(response.service, services.RequestTransferExit)
self.assertEqual(response.service_data.parameter_records, b'\x89\xab\xcd\xef')
def test_init(self):
dtc = Dtc(0x1234)
self.assertEqual(dtc.id, 0x1234 )
self.assertEqual(dtc.status.get_byte(), b'\x00')
self.assertEqual(dtc.status.get_byte_as_int(), 0x00)
self.assertEqual(dtc.severity.get_byte(), b'\x00')
self.assertEqual(dtc.severity.get_byte_as_int(), 0x00)
self.assertEqual(dtc.status.test_failed, False)
self.assertEqual(dtc.status.test_failed_this_operation_cycle, False)
self.assertEqual(dtc.status.pending, False)
self.assertEqual(dtc.status.confirmed, False)
self.assertEqual(dtc.status.test_not_completed_since_last_clear, False)
self.assertEqual(dtc.status.test_failed_since_last_clear, False)
self.assertEqual(dtc.status.test_not_completed_this_operation_cycle, False)
self.assertEqual(dtc.status.warning_indicator_requested, False)
with self.assertRaises(TypeError):
def _test_bad_echo_ali_no_exception(self):
self.udsclient.config['exception_on_unexpected_response'] = False
memloc = MemoryLocation(address=0x1234, memorysize=4, address_format=16, memorysize_format=8)
response = self.udsclient.write_memory_by_address(memloc, b'\x66\x77\x88\x99')
self.assertTrue(response.valid)
self.assertTrue(response.unexpected)
def _test_request_invalid_service_no_exception(self):
self.udsclient.config['exception_on_invalid_response'] = False
memloc = MemoryLocation(address=0x1234, memorysize=4, address_format=16, memorysize_format=8)
response = self.udsclient.write_memory_by_address(memloc, b'\x66\x77\x88\x99')
self.assertFalse(response.valid)
def test_memloc_autosize2(self):
memloc = MemoryLocation(address=0x1234567, memorysize=0x789abb)
self.assertEqual(memloc.get_address_bytes(), b'\x01\x23\x45\x67')
self.assertEqual(memloc.get_memorysize_bytes(), b'\x78\x9a\xbb')
def _test_4byte_block(self):
memloc = MemoryLocation(address=0x1234, memorysize=4, address_format=16, memorysize_format=8)
response = self.udsclient.write_memory_by_address(memloc, b'\x66\x77\x88\x99')
self.assertEqual(response.service_data.alfid_echo, memloc.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_memloc_from_bytes(self):
memloc = MemoryLocation.from_bytes(address_bytes=b'\x12\x34', memorysize_bytes=b'\xFF')
self.assertEqual(memloc.address, 0x1234)
self.assertEqual(memloc.memorysize, 0xFF)
self.assertEqual(memloc.address_format, 16)
self.assertEqual(memloc.memorysize_format, 8)
memloc = MemoryLocation.from_bytes(address_bytes=b'\x12\x34\x56', memorysize_bytes=b'\x66\x77\x88')
self.assertEqual(memloc.address, 0x123456)
self.assertEqual(memloc.memorysize, 0x667788)
self.assertEqual(memloc.address_format, 24)
self.assertEqual(memloc.memorysize_format, 24)
def test_memloc1(self):
memloc = MemoryLocation(address=0x1234, memorysize=0x78, address_format=16, memorysize_format=8)
self.assertEqual(memloc.get_address_bytes(), b'\x12\x34')
self.assertEqual(memloc.get_memorysize_bytes(), b'\x78')
def _test_request_upload_invalidservice_no_exception(self):
self.udsclient.config['exception_on_invalid_response'] = False
memloc = MemoryLocation(address=0x1234, memorysize=0xFF, address_format=16, memorysize_format=8)
response = self.udsclient.request_upload(memory_location=memloc)
self.assertFalse(response.valid)
def _test_request_invalid_service_exception(self):
with self.assertRaises(InvalidResponseException) as handle:
self.udsclient.read_memory_by_address(MemoryLocation(address=0x1234, memorysize=4, address_format=16, memorysize_format=8))