|
99 | 99 | diagnostic_request = bytearray( |
100 | 100 | [int(x, 16) for x in "02 fd 80 01 00 00 00 07 0e 00 00 01 00 01 02".split(" ")] |
101 | 101 | ) |
| 102 | +diagnostic_request_to_address = bytearray( |
| 103 | + [int(x, 16) for x in "02 fd 80 01 00 00 00 07 0e 00 12 34 00 01 02".split(" ")] |
| 104 | +) |
102 | 105 | unknown_mercedes_message = bytearray( |
103 | 106 | [ |
104 | 107 | int(x, 16) |
@@ -500,6 +503,22 @@ def test_send_diagnostic_negative(mock_socket): |
500 | 503 | assert mock_socket.tx_queue[-1] == diagnostic_request |
501 | 504 |
|
502 | 505 |
|
| 506 | +def test_send_diagnostic_to_address_positive(mock_socket): |
| 507 | + sut = DoIPClient(test_ip, test_logical_address) |
| 508 | + mock_socket.rx_queue.append(diagnostic_positive_response) |
| 509 | + assert None == sut.send_diagnostic_to_address(0x1234, bytearray([0, 1, 2])) |
| 510 | + assert mock_socket.tx_queue[-1] == diagnostic_request_to_address |
| 511 | + |
| 512 | +def test_send_diagnostic_to_address_negative(mock_socket): |
| 513 | + sut = DoIPClient(test_ip, test_logical_address) |
| 514 | + mock_socket.rx_queue.append(diagnostic_negative_response) |
| 515 | + with pytest.raises( |
| 516 | + IOError, match=r"Diagnostic request rejected with negative acknowledge code" |
| 517 | + ): |
| 518 | + result = sut.send_diagnostic_to_address(0x1234, bytearray([0, 1, 2])) |
| 519 | + assert mock_socket.tx_queue[-1] == diagnostic_request_to_address |
| 520 | + |
| 521 | + |
503 | 522 | def test_receive_diagnostic(mock_socket): |
504 | 523 | sut = DoIPClient(test_ip, test_logical_address) |
505 | 524 | mock_socket.rx_queue.append(diagnostic_result) |
|
0 commit comments