diff --git a/device-types/APC/BX750MI-GR.yaml b/device-types/APC/BX750MI-GR.yaml index c8b8afdd..6203844e 100644 --- a/device-types/APC/BX750MI-GR.yaml +++ b/device-types/APC/BX750MI-GR.yaml @@ -15,7 +15,7 @@ comments: '[BX750MI-GR Datasheet by Kolyan](https://www.apc.com/kz/ru/product/BX front-ports: - name: IN type: 8p8c - rear_port: '1' + rear_port: OUT rear_port_position: 1 rear-ports: - name: OUT diff --git a/tests/definitions_test.py b/tests/definitions_test.py index 09cae823..f7f47996 100644 --- a/tests/definitions_test.py +++ b/tests/definitions_test.py @@ -193,6 +193,29 @@ def test_definitions(file_path, schema, change_type): # A module this_device = ModuleType(definition, file_path, change_type) + # Validate that front-ports reference existing rear-ports + if this_device.isDevice: + rear_ports = definition.get("rear-ports", []) or [] + front_ports = definition.get("front-ports", []) or [] + + rear_port_names = { + rp.get("name") for rp in rear_ports if isinstance(rp, dict) + } + + for fp in front_ports: + if not isinstance(fp, dict): + continue + + rear_port_ref = fp.get("rear_port") + + if rear_port_ref and rear_port_ref not in rear_port_names: + pytest.fail( + f"{file_path}: front-port '{fp.get('name')}' references " + f"rear_port '{rear_port_ref}', but no such rear-port exists. " + f"Defined rear-ports: {sorted(rear_port_names)}", + pytrace=False, + ) + # Verify the slug is valid, only if the definition type is a Device if this_device.isDevice: assert this_device.verify_slug(KNOWN_SLUGS), pytest.fail(this_device.failureMessage, False)