Skip to content

Commit

Permalink
pythonvalidate: Add more info to errors
Browse files Browse the repository at this point in the history
  • Loading branch information
jarofgreen committed Nov 9, 2022
1 parent 20bcfce commit 2a5e5cd
Show file tree
Hide file tree
Showing 17 changed files with 134 additions and 26 deletions.
24 changes: 22 additions & 2 deletions libcoveofds/python_validate.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,13 +87,18 @@ def check_node_first_pass(self, node: dict):
type = location.get("type")
if type != "Point":
self._additional_check_results.append(
{"type": "node_location_type_incorrect", "node_id": node.get("id")}
{
"type": "node_location_type_incorrect",
"node_id": node.get("id"),
"incorrect_type": type,
}
)
if not self._is_json_coordinates(location.get("coordinates")):
self._additional_check_results.append(
{
"type": "node_location_coordinates_incorrect",
"node_id": node.get("id"),
"incorrect_coordinates": location.get("coordinates"),
}
)

Expand All @@ -103,13 +108,18 @@ def check_span_first_pass(self, span: dict):
type = location.get("type")
if type != "LineString":
self._additional_check_results.append(
{"type": "span_route_type_incorrect", "span_id": span.get("id")}
{
"type": "span_route_type_incorrect",
"span_id": span.get("id"),
"incorrect_type": type,
}
)
if not self._is_json_list_coordinates(location.get("coordinates")):
self._additional_check_results.append(
{
"type": "span_route_coordinates_incorrect",
"span_id": span.get("id"),
"incorrect_coordinates": location.get("coordinates"),
}
)

Expand Down Expand Up @@ -212,14 +222,19 @@ def _check_related_phase_object(
if id in self._phases:
# check - if name is set on reference but not on original
if name and not self._phases[id]:
name_set_but_not_in_original_result.update(
{"name_in_reference": name}
)
self._additional_check_results.append(
name_set_but_not_in_original_result
)
# check - if names are both set, do they match?
if name and self._phases[id] and name != self._phases[id]:
name_not_match_result.update({"name_in_reference": name})
self._additional_check_results.append(name_not_match_result)
else:
# check failed - id is not known
id_not_found_result.update({"phase_id_not_found": id})
self._additional_check_results.append(id_not_found_result)


Expand Down Expand Up @@ -372,14 +387,19 @@ def _check_related_organisation_object(
if id in self._organisations:
# check - if name is set on reference but not on original
if name and not self._organisations[id]:
name_set_but_not_in_original_result.update(
{"name_in_reference": name}
)
self._additional_check_results.append(
name_set_but_not_in_original_result
)
# check - if names are both set, do they match?
if name and self._organisations[id] and name != self._organisations[id]:
name_not_match_result.update({"name_in_reference": name})
self._additional_check_results.append(name_not_match_result)
else:
# check failed - id is not known
id_not_found_result.update({"organisation_id_not_found": id})
self._additional_check_results.append(id_not_found_result)


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,60 @@
{
"type": "node_location_coordinates_incorrect",
"node_id": "1",
"incorrect_coordinates": [
[
-0.173,
5.626
],
[
-0.178,
5.807
],
[
-0.112,
5.971
],
[
-0.211,
5.963
],
[
-0.321,
6.17
],
[
-0.488,
6.29
],
[
-0.56,
6.421
],
[
-0.752,
6.533
],
[
-0.867,
6.607
],
[
-1.101,
6.585
],
[
-1.304,
6.623
],
[
-1.461,
6.727
],
[
-1.628,
6.713
]
],
"network_id": "a096d627-72e1-4f9b-b129-951b1737bff4"
}
]
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
{
"type": "node_location_type_incorrect",
"node_id": "1",
"incorrect_type": "LineString",
"network_id": "a096d627-72e1-4f9b-b129-951b1737bff4"
}
]
Original file line number Diff line number Diff line change
Expand Up @@ -3,35 +3,41 @@
"type": "node_organisation_reference_id_not_found",
"node_id": "1",
"field": "physicalInfrastructureProvider",
"organisation_id_not_found": "2",
"network_id": "a096d627-72e1-4f9b-b129-951b1737bff4"
},
{
"type": "node_organisation_reference_id_not_found",
"node_id": "1",
"field": "networkProvider",
"organisation_id_not_found": "3",
"network_id": "a096d627-72e1-4f9b-b129-951b1737bff4"
},
{
"type": "span_organisation_reference_id_not_found",
"span_id": "1",
"field": "physicalInfrastructureProvider",
"organisation_id_not_found": "4",
"network_id": "a096d627-72e1-4f9b-b129-951b1737bff4"
},
{
"type": "span_organisation_reference_id_not_found",
"span_id": "1",
"field": "networkProvider",
"organisation_id_not_found": "5",
"network_id": "a096d627-72e1-4f9b-b129-951b1737bff4"
},
{
"type": "span_organisation_reference_id_not_found",
"span_id": "1",
"field": "supplier",
"organisation_id_not_found": "6",
"network_id": "a096d627-72e1-4f9b-b129-951b1737bff4"
},
{
"type": "phase_organisation_reference_id_not_found",
"phase_id": "1",
"organisation_id_not_found": "7",
"network_id": "a096d627-72e1-4f9b-b129-951b1737bff4"
}
]
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"id": "2"
},
"networkProvider": {
"id": "2"
"id": "3"
}
},
{
Expand All @@ -24,13 +24,13 @@
"id": "1",
"name": "Accra to Kumasi",
"physicalInfrastructureProvider": {
"id": "2"
"id": "4"
},
"networkProvider": {
"id": "2"
"id": "5"
},
"supplier": {
"id": "2"
"id": "6"
},
"start": "1",
"end": "2"
Expand All @@ -43,7 +43,7 @@
"description": "The first phase of the Ghana Fibre Network NextGen roll-out.",
"funders": [
{
"id": "2"
"id": "7"
}
]
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,35 +3,41 @@
"type": "node_organisation_reference_name_does_not_match",
"node_id": "1",
"field": "physicalInfrastructureProvider",
"name_in_reference": "Nothing Nowhere A",
"network_id": "a096d627-72e1-4f9b-b129-951b1737bff4"
},
{
"type": "node_organisation_reference_name_does_not_match",
"node_id": "1",
"field": "networkProvider",
"name_in_reference": "Nothing Nowhere B",
"network_id": "a096d627-72e1-4f9b-b129-951b1737bff4"
},
{
"type": "span_organisation_reference_name_does_not_match",
"span_id": "1",
"field": "physicalInfrastructureProvider",
"name_in_reference": "Nothing Nowhere C",
"network_id": "a096d627-72e1-4f9b-b129-951b1737bff4"
},
{
"type": "span_organisation_reference_name_does_not_match",
"span_id": "1",
"field": "networkProvider",
"name_in_reference": "Nothing Nowhere D",
"network_id": "a096d627-72e1-4f9b-b129-951b1737bff4"
},
{
"type": "span_organisation_reference_name_does_not_match",
"span_id": "1",
"field": "supplier",
"name_in_reference": "Nothing Nowhere E",
"network_id": "a096d627-72e1-4f9b-b129-951b1737bff4"
},
{
"type": "phase_organisation_reference_name_does_not_match",
"phase_id": "1",
"name_in_reference": "Nothing Nowhere F",
"network_id": "a096d627-72e1-4f9b-b129-951b1737bff4"
}
]
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@
"name": "Accra",
"physicalInfrastructureProvider": {
"id": "1",
"name": "Nothing Nowhere"
"name": "Nothing Nowhere A"
},
"networkProvider": {
"id": "1",
"name": "Nothing Nowhere"
"name": "Nothing Nowhere B"
}
},
{
Expand All @@ -27,15 +27,15 @@
"name": "Accra to Kumasi",
"physicalInfrastructureProvider": {
"id": "1",
"name": "Nothing Nowhere"
"name": "Nothing Nowhere C"
},
"networkProvider": {
"id": "1",
"name": "Nothing Nowhere"
"name": "Nothing Nowhere D"
},
"supplier": {
"id": "1",
"name": "Nothing Nowhere"
"name": "Nothing Nowhere E"
},
"start": "1",
"end": "2"
Expand All @@ -49,7 +49,7 @@
"funders": [
{
"id": "1",
"name": "Nothing Nowhere"
"name": "Nothing Nowhere F"
}
]
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,35 +3,41 @@
"type": "node_organisation_reference_name_set_but_not_in_original",
"node_id": "1",
"field": "physicalInfrastructureProvider",
"name_in_reference": "Nothing Nowhere A",
"network_id": "a096d627-72e1-4f9b-b129-951b1737bff4"
},
{
"type": "node_organisation_reference_name_set_but_not_in_original",
"node_id": "1",
"field": "networkProvider",
"name_in_reference": "Nothing Nowhere B",
"network_id": "a096d627-72e1-4f9b-b129-951b1737bff4"
},
{
"type": "span_organisation_reference_name_set_but_not_in_original",
"span_id": "1",
"field": "physicalInfrastructureProvider",
"name_in_reference": "Nothing Nowhere C",
"network_id": "a096d627-72e1-4f9b-b129-951b1737bff4"
},
{
"type": "span_organisation_reference_name_set_but_not_in_original",
"span_id": "1",
"field": "networkProvider",
"name_in_reference": "Nothing Nowhere D",
"network_id": "a096d627-72e1-4f9b-b129-951b1737bff4"
},
{
"type": "span_organisation_reference_name_set_but_not_in_original",
"span_id": "1",
"field": "supplier",
"name_in_reference": "Nothing Nowhere E",
"network_id": "a096d627-72e1-4f9b-b129-951b1737bff4"
},
{
"type": "phase_organisation_reference_name_set_but_not_in_original",
"phase_id": "1",
"name_in_reference": "Nothing Nowhere F",
"network_id": "a096d627-72e1-4f9b-b129-951b1737bff4"
}
]
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@
"name": "Accra",
"physicalInfrastructureProvider": {
"id": "1",
"name": "Nothing Nowhere"
"name": "Nothing Nowhere A"
},
"networkProvider": {
"id": "1",
"name": "Nothing Nowhere"
"name": "Nothing Nowhere B"
}
},
{
Expand All @@ -27,15 +27,15 @@
"name": "Accra to Kumasi",
"physicalInfrastructureProvider": {
"id": "1",
"name": "Nothing Nowhere"
"name": "Nothing Nowhere C"
},
"networkProvider": {
"id": "1",
"name": "Nothing Nowhere"
"name": "Nothing Nowhere D"
},
"supplier": {
"id": "1",
"name": "Nothing Nowhere"
"name": "Nothing Nowhere E"
},
"start": "1",
"end": "2"
Expand All @@ -49,7 +49,7 @@
"funders": [
{
"id": "1",
"name": "Nothing Nowhere"
"name": "Nothing Nowhere F"
}
]
}
Expand Down
Loading

0 comments on commit 2a5e5cd

Please sign in to comment.