from __future__ import annotations

from pymulator.core.uds import ServiceId

from .conftest import attach_ecu, bus_and_client, collect_isotp_payload, load_handler, send_isotp_request


def test_obd2_vin_multiframe_response(bus_and_client):
    bus, client = bus_and_client
    session = load_handler("obd2.json")
    attach_ecu(bus, "OBD2", session)

    send_isotp_request(bus, client, session.arbitration_id, [ServiceId.vehicle_information, 0x02])
    payload = collect_isotp_payload(bus, client, session.arbitration_id, timeout=2.0)

    assert payload[:2] == [0x49, 0x02]
    assert bytes(payload[2:]) == bytes.fromhex("54 45 53 54 56 49 4E 31 32 33 34 35 36 37 38 39")
