Skip to content

Commit

Permalink
pythonvalidate: unique ID checks return a path with "id" at the end
Browse files Browse the repository at this point in the history
  • Loading branch information
jarofgreen committed Dec 21, 2022
1 parent 4ac74b6 commit 0bfad6d
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 30 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
22 changes: 17 additions & 5 deletions libcoveofds/python_validate.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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():
Expand All @@ -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
Expand Down
20 changes: 10 additions & 10 deletions tests/fixtures/pythonvalidate/unique_ids_1.expected.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
]
30 changes: 15 additions & 15 deletions tests/fixtures/pythonvalidate/unique_ids_2.expected.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
]

0 comments on commit 0bfad6d

Please sign in to comment.