fix: Detect duplicates between front<->rear ports mapping (#3821)
* fix: extend front/rear port check to modules * fix: detect duplicates between front<->rear ports mapping --------- Co-authored-by: Harry <Harry@cadby.co.uk>
This commit is contained in:
@@ -31,7 +31,7 @@ front-ports:
|
||||
color: 00ffff
|
||||
- name: '{module}:B-2'
|
||||
type: mpo
|
||||
rear_port: '{module}:A-2'
|
||||
rear_port: '{module}:B-2'
|
||||
rear_port_position: 1
|
||||
color: 00ffff
|
||||
- name: '{module}:B-3'
|
||||
|
||||
@@ -26,7 +26,7 @@ front-ports:
|
||||
rear_port_position: 1
|
||||
- name: '{module}:B-2'
|
||||
type: mpo
|
||||
rear_port: '{module}:A-2'
|
||||
rear_port: '{module}:B-2'
|
||||
rear_port_position: 1
|
||||
- name: '{module}:B-3'
|
||||
type: mpo
|
||||
|
||||
@@ -211,6 +211,7 @@ def test_definitions(file_path, schema, change_type):
|
||||
rp.get("name") for rp in rear_ports if isinstance(rp, dict)
|
||||
}
|
||||
|
||||
rear_port_positions = {}
|
||||
for fp in front_ports:
|
||||
if not isinstance(fp, dict):
|
||||
continue
|
||||
@@ -225,6 +226,19 @@ def test_definitions(file_path, schema, change_type):
|
||||
pytrace=False,
|
||||
)
|
||||
|
||||
# Check for duplicate (rear_port, rear_port_position) combinations
|
||||
if rear_port_ref:
|
||||
rear_port_pos = fp.get("rear_port_position", 1)
|
||||
key = (rear_port_ref, rear_port_pos)
|
||||
if key in rear_port_positions:
|
||||
pytest.fail(
|
||||
f"{file_path}: front-port '{fp.get('name')}' has duplicate "
|
||||
f"(rear_port, rear_port_position) = ('{rear_port_ref}', {rear_port_pos}). "
|
||||
f"Already used by front-port '{rear_port_positions[key]}'.",
|
||||
pytrace=False,
|
||||
)
|
||||
rear_port_positions[key] = fp.get("name")
|
||||
|
||||
# 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)
|
||||
|
||||
Reference in New Issue
Block a user