Add duplicate component test

This commit is contained in:
Daniel Sheppard 2020-11-24 13:10:31 -06:00 committed by GitHub
parent 4293f184a8
commit f9704f0736
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -39,3 +39,23 @@ def test_dupes(file_path):
pytest.fail(f"{file_path} is a duplicate device_type for {slug}", False)
KNOWN_MODELS[slug] = definition.get('model')
def test_components(type):
KNOWN = []
components = definition.get(type, None)
if components is not None:
for idx,component in enumerate(components):
name = component.get('name')
if name in KNOWN:
pytest.fail(f'Duplicate {type} "{name}" in {file_path}', False)
KNOWN.append(name)
test_components('interfaces')
test_components('device-bays')
test_components('front-ports')
test_components('rear-ports')
test_components('power-ports')
test_components('power-outlets')
test_components('console-ports')
test_components('console-server-ports')