From 0bfad6d78f3187952ca4acb808e7d73efe6edf31 Mon Sep 17 00:00:00 2001 From: James Date: Wed, 21 Dec 2022 09:51:33 +0000 Subject: [PATCH] pythonvalidate: unique ID checks return a path with "id" at the end https://github.com/Open-Telecoms-Data/lib-cove-ofds/issues/60 --- CHANGELOG.md | 1 + libcoveofds/python_validate.py | 22 ++++++++++---- .../pythonvalidate/unique_ids_1.expected.json | 20 ++++++------- .../pythonvalidate/unique_ids_2.expected.json | 30 +++++++++---------- 4 files changed, 43 insertions(+), 30 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 28643d6..9d05140 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. - Python Validate: - [#51](https://github.com/Open-Telecoms-Data/lib-cove-ofds/issues/51) - unique ID checks return all places the non-unique ID is used. (Previously would not return first one) + - [#60](https://github.com/Open-Telecoms-Data/lib-cove-ofds/issues/60) - unique ID checks return a path with "id" at the end. ## [0.6.0] - 2022-12-07 diff --git a/libcoveofds/python_validate.py b/libcoveofds/python_validate.py index 73d48ad..19533ae 100644 --- a/libcoveofds/python_validate.py +++ b/libcoveofds/python_validate.py @@ -557,19 +557,31 @@ def get_additional_check_results(self) -> list: if len(paths) > 1: for path in paths: out.append( - {"type": "duplicate_node_id", "node_id": id, "path": path} + { + "type": "duplicate_node_id", + "node_id": id, + "path": path + "/id", + } ) for id, paths in self._span_ids_seen.items(): if len(paths) > 1: for path in paths: out.append( - {"type": "duplicate_span_id", "span_id": id, "path": path} + { + "type": "duplicate_span_id", + "span_id": id, + "path": path + "/id", + } ) for id, paths in self._phase_ids_seen.items(): if len(paths) > 1: for path in paths: out.append( - {"type": "duplicate_phase_id", "phase_id": id, "path": path} + { + "type": "duplicate_phase_id", + "phase_id": id, + "path": path + "/id", + } ) for id, paths in self._organisation_ids_seen.items(): if len(paths) > 1: @@ -578,7 +590,7 @@ def get_additional_check_results(self) -> list: { "type": "duplicate_organisation_id", "organisation_id": id, - "path": path, + "path": path + "/id", } ) for id, paths in self._contract_ids_seen.items(): @@ -588,7 +600,7 @@ def get_additional_check_results(self) -> list: { "type": "duplicate_contract_id", "contract_id": id, - "path": path, + "path": path + "/id", } ) return out diff --git a/tests/fixtures/pythonvalidate/unique_ids_1.expected.json b/tests/fixtures/pythonvalidate/unique_ids_1.expected.json index f93b6c0..da2b172 100644 --- a/tests/fixtures/pythonvalidate/unique_ids_1.expected.json +++ b/tests/fixtures/pythonvalidate/unique_ids_1.expected.json @@ -2,61 +2,61 @@ { "type": "duplicate_node_id", "node_id": "2", - "path": "/networks/0/nodes/1", + "path": "/networks/0/nodes/1/id", "network_id": "a096d627-72e1-4f9b-b129-951b1737bff4" }, { "type": "duplicate_node_id", "node_id": "2", - "path": "/networks/0/nodes/2", + "path": "/networks/0/nodes/2/id", "network_id": "a096d627-72e1-4f9b-b129-951b1737bff4" }, { "type": "duplicate_span_id", "span_id": "1", - "path": "/networks/0/spans/0", + "path": "/networks/0/spans/0/id", "network_id": "a096d627-72e1-4f9b-b129-951b1737bff4" }, { "type": "duplicate_span_id", "span_id": "1", - "path": "/networks/0/spans/1", + "path": "/networks/0/spans/1/id", "network_id": "a096d627-72e1-4f9b-b129-951b1737bff4" }, { "type": "duplicate_phase_id", "phase_id": "2", - "path": "/networks/0/phases/0", + "path": "/networks/0/phases/0/id", "network_id": "a096d627-72e1-4f9b-b129-951b1737bff4" }, { "type": "duplicate_phase_id", "phase_id": "2", - "path": "/networks/0/phases/1", + "path": "/networks/0/phases/1/id", "network_id": "a096d627-72e1-4f9b-b129-951b1737bff4" }, { "type": "duplicate_organisation_id", "organisation_id": "2", - "path": "/networks/0/organisations/0", + "path": "/networks/0/organisations/0/id", "network_id": "a096d627-72e1-4f9b-b129-951b1737bff4" }, { "type": "duplicate_organisation_id", "organisation_id": "2", - "path": "/networks/0/organisations/1", + "path": "/networks/0/organisations/1/id", "network_id": "a096d627-72e1-4f9b-b129-951b1737bff4" }, { "type": "duplicate_contract_id", "contract_id": "2", - "path": "/networks/0/contracts/0", + "path": "/networks/0/contracts/0/id", "network_id": "a096d627-72e1-4f9b-b129-951b1737bff4" }, { "type": "duplicate_contract_id", "contract_id": "2", - "path": "/networks/0/contracts/1", + "path": "/networks/0/contracts/1/id", "network_id": "a096d627-72e1-4f9b-b129-951b1737bff4" } ] diff --git a/tests/fixtures/pythonvalidate/unique_ids_2.expected.json b/tests/fixtures/pythonvalidate/unique_ids_2.expected.json index c5206cc..d3bafc1 100644 --- a/tests/fixtures/pythonvalidate/unique_ids_2.expected.json +++ b/tests/fixtures/pythonvalidate/unique_ids_2.expected.json @@ -2,91 +2,91 @@ { "type": "duplicate_node_id", "node_id": "2", - "path": "/networks/0/nodes/1", + "path": "/networks/0/nodes/1/id", "network_id": "a096d627-72e1-4f9b-b129-951b1737bff4" }, { "type": "duplicate_node_id", "node_id": "2", - "path": "/networks/0/nodes/2", + "path": "/networks/0/nodes/2/id", "network_id": "a096d627-72e1-4f9b-b129-951b1737bff4" }, { "type": "duplicate_node_id", "node_id": "2", - "path": "/networks/0/nodes/3", + "path": "/networks/0/nodes/3/id", "network_id": "a096d627-72e1-4f9b-b129-951b1737bff4" }, { "type": "duplicate_span_id", "span_id": "1", - "path": "/networks/0/spans/0", + "path": "/networks/0/spans/0/id", "network_id": "a096d627-72e1-4f9b-b129-951b1737bff4" }, { "type": "duplicate_span_id", "span_id": "1", - "path": "/networks/0/spans/1", + "path": "/networks/0/spans/1/id", "network_id": "a096d627-72e1-4f9b-b129-951b1737bff4" }, { "type": "duplicate_span_id", "span_id": "1", - "path": "/networks/0/spans/2", + "path": "/networks/0/spans/2/id", "network_id": "a096d627-72e1-4f9b-b129-951b1737bff4" }, { "type": "duplicate_phase_id", "phase_id": "2", - "path": "/networks/0/phases/0", + "path": "/networks/0/phases/0/id", "network_id": "a096d627-72e1-4f9b-b129-951b1737bff4" }, { "type": "duplicate_phase_id", "phase_id": "2", - "path": "/networks/0/phases/1", + "path": "/networks/0/phases/1/id", "network_id": "a096d627-72e1-4f9b-b129-951b1737bff4" }, { "type": "duplicate_phase_id", "phase_id": "2", - "path": "/networks/0/phases/2", + "path": "/networks/0/phases/2/id", "network_id": "a096d627-72e1-4f9b-b129-951b1737bff4" }, { "type": "duplicate_organisation_id", "organisation_id": "2", - "path": "/networks/0/organisations/0", + "path": "/networks/0/organisations/0/id", "network_id": "a096d627-72e1-4f9b-b129-951b1737bff4" }, { "type": "duplicate_organisation_id", "organisation_id": "2", - "path": "/networks/0/organisations/1", + "path": "/networks/0/organisations/1/id", "network_id": "a096d627-72e1-4f9b-b129-951b1737bff4" }, { "type": "duplicate_organisation_id", "organisation_id": "2", - "path": "/networks/0/organisations/2", + "path": "/networks/0/organisations/2/id", "network_id": "a096d627-72e1-4f9b-b129-951b1737bff4" }, { "type": "duplicate_contract_id", "contract_id": "2", - "path": "/networks/0/contracts/0", + "path": "/networks/0/contracts/0/id", "network_id": "a096d627-72e1-4f9b-b129-951b1737bff4" }, { "type": "duplicate_contract_id", "contract_id": "2", - "path": "/networks/0/contracts/1", + "path": "/networks/0/contracts/1/id", "network_id": "a096d627-72e1-4f9b-b129-951b1737bff4" }, { "type": "duplicate_contract_id", "contract_id": "2", - "path": "/networks/0/contracts/2", + "path": "/networks/0/contracts/2/id", "network_id": "a096d627-72e1-4f9b-b129-951b1737bff4" } ]