Keep B2 client fixes and move VPS implementation to its standalone repository
This commit is contained in:
@@ -0,0 +1,51 @@
|
||||
"""Synthetic 0.06 compatibility: keep unknown fields and reject unobserved versions."""
|
||||
# ruff: noqa: F811 -- imported pytest fixtures are injected by parameter name.
|
||||
|
||||
import pytest
|
||||
from test_equipment_network import context, full_core_context # noqa: F401
|
||||
|
||||
from k1link.device_plugins.arnavi_b2.usb_protocol import ProtocolError, decode_configuration
|
||||
from k1link.device_plugins.arnavi_b2.web_protocol import decode_request
|
||||
from k1link.fleet import equipment_actions, equipment_network
|
||||
from k1link.fleet.independent_equipment import EquipmentError
|
||||
|
||||
|
||||
def test_core_propagates_actual_firmware_and_preserves_unknown_config(full_core_context):
|
||||
equipment, _, row, config = full_core_context
|
||||
row["observed"]["firmware"] = "0.06"
|
||||
action = equipment_actions.plan(equipment, row, {"kind": "request-position"})
|
||||
assert action["firmware"] == "0.06"
|
||||
planned = equipment_network.plan(equipment, row, full=True)
|
||||
assert planned["firmware"] == "0.06"
|
||||
target = decode_configuration(bytes.fromhex(planned["target_configuration"]))
|
||||
assert target.integer(25, 2) == 16
|
||||
assert target.value(222) == config.value(222)
|
||||
assert [r.number for r in target.records] == [r.number for r in config.records]
|
||||
row["observed"]["firmware"] = "0.07"
|
||||
with pytest.raises(EquipmentError):
|
||||
equipment_actions.plan(equipment, row, {"kind": "request-position"})
|
||||
with pytest.raises(EquipmentError):
|
||||
equipment_network.plan(equipment, row, full=True)
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"metadata,accepted",
|
||||
[
|
||||
("0001e7020000", True),
|
||||
("0006e7020000", True),
|
||||
("0007e7020000", False),
|
||||
("0006e7030000", False),
|
||||
("0006e7020001", False),
|
||||
],
|
||||
)
|
||||
def test_web006_upload_keeps_crc_image(metadata, accepted, full_core_context):
|
||||
*_, config = full_core_context
|
||||
payload = config.encode()
|
||||
body = int("123456789012345").to_bytes(8, "little")
|
||||
body += bytes.fromhex(metadata) + b"\x05" + payload
|
||||
frame = b"[\x01" + len(body).to_bytes(2, "big") + body + b"]"
|
||||
if accepted:
|
||||
assert decode_request(frame)[1:] == (5, payload)
|
||||
else:
|
||||
with pytest.raises(ProtocolError):
|
||||
decode_request(frame)
|
||||
Reference in New Issue
Block a user