diff --git a/libcoveofds/python_validate.py b/libcoveofds/python_validate.py index d1d8f51..7b37c9e 100644 --- a/libcoveofds/python_validate.py +++ b/libcoveofds/python_validate.py @@ -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"), } ) @@ -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"), } ) @@ -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) @@ -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) diff --git a/tests/fixtures/pythonvalidate/node_location_coordinates_incorrect_1.expected.json b/tests/fixtures/pythonvalidate/node_location_coordinates_incorrect_1.expected.json index b3f7984..3856293 100644 --- a/tests/fixtures/pythonvalidate/node_location_coordinates_incorrect_1.expected.json +++ b/tests/fixtures/pythonvalidate/node_location_coordinates_incorrect_1.expected.json @@ -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" } ] diff --git a/tests/fixtures/pythonvalidate/node_location_type_incorrect_1.expected.json b/tests/fixtures/pythonvalidate/node_location_type_incorrect_1.expected.json index e52a9e7..d71a38d 100644 --- a/tests/fixtures/pythonvalidate/node_location_type_incorrect_1.expected.json +++ b/tests/fixtures/pythonvalidate/node_location_type_incorrect_1.expected.json @@ -2,6 +2,7 @@ { "type": "node_location_type_incorrect", "node_id": "1", + "incorrect_type": "LineString", "network_id": "a096d627-72e1-4f9b-b129-951b1737bff4" } ] diff --git a/tests/fixtures/pythonvalidate/organisation_id_not_found_1.expected.json b/tests/fixtures/pythonvalidate/organisation_id_not_found_1.expected.json index 89e7047..af2ed64 100644 --- a/tests/fixtures/pythonvalidate/organisation_id_not_found_1.expected.json +++ b/tests/fixtures/pythonvalidate/organisation_id_not_found_1.expected.json @@ -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" } ] diff --git a/tests/fixtures/pythonvalidate/organisation_id_not_found_1.input.json b/tests/fixtures/pythonvalidate/organisation_id_not_found_1.input.json index 9eb7c04..fb239a0 100644 --- a/tests/fixtures/pythonvalidate/organisation_id_not_found_1.input.json +++ b/tests/fixtures/pythonvalidate/organisation_id_not_found_1.input.json @@ -11,7 +11,7 @@ "id": "2" }, "networkProvider": { - "id": "2" + "id": "3" } }, { @@ -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" @@ -43,7 +43,7 @@ "description": "The first phase of the Ghana Fibre Network NextGen roll-out.", "funders": [ { - "id": "2" + "id": "7" } ] } diff --git a/tests/fixtures/pythonvalidate/organisation_name_not_match_1.expected.json b/tests/fixtures/pythonvalidate/organisation_name_not_match_1.expected.json index 8537065..9c6f1ff 100644 --- a/tests/fixtures/pythonvalidate/organisation_name_not_match_1.expected.json +++ b/tests/fixtures/pythonvalidate/organisation_name_not_match_1.expected.json @@ -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" } ] diff --git a/tests/fixtures/pythonvalidate/organisation_name_not_match_1.input.json b/tests/fixtures/pythonvalidate/organisation_name_not_match_1.input.json index d1b584a..db733bf 100644 --- a/tests/fixtures/pythonvalidate/organisation_name_not_match_1.input.json +++ b/tests/fixtures/pythonvalidate/organisation_name_not_match_1.input.json @@ -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" } }, { @@ -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" @@ -49,7 +49,7 @@ "funders": [ { "id": "1", - "name": "Nothing Nowhere" + "name": "Nothing Nowhere F" } ] } diff --git a/tests/fixtures/pythonvalidate/organisation_reference_name_set_but_not_in_original_1.expected.json b/tests/fixtures/pythonvalidate/organisation_reference_name_set_but_not_in_original_1.expected.json index d1c0150..dadfe80 100644 --- a/tests/fixtures/pythonvalidate/organisation_reference_name_set_but_not_in_original_1.expected.json +++ b/tests/fixtures/pythonvalidate/organisation_reference_name_set_but_not_in_original_1.expected.json @@ -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" } ] diff --git a/tests/fixtures/pythonvalidate/organisation_reference_name_set_but_not_in_original_1.input.json b/tests/fixtures/pythonvalidate/organisation_reference_name_set_but_not_in_original_1.input.json index 9738eea..bae14bd 100644 --- a/tests/fixtures/pythonvalidate/organisation_reference_name_set_but_not_in_original_1.input.json +++ b/tests/fixtures/pythonvalidate/organisation_reference_name_set_but_not_in_original_1.input.json @@ -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" } }, { @@ -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" @@ -49,7 +49,7 @@ "funders": [ { "id": "1", - "name": "Nothing Nowhere" + "name": "Nothing Nowhere F" } ] } diff --git a/tests/fixtures/pythonvalidate/phase_id_not_found_1.expected.json b/tests/fixtures/pythonvalidate/phase_id_not_found_1.expected.json index 930c5cf..cef310a 100644 --- a/tests/fixtures/pythonvalidate/phase_id_not_found_1.expected.json +++ b/tests/fixtures/pythonvalidate/phase_id_not_found_1.expected.json @@ -2,16 +2,19 @@ { "type": "node_phase_reference_id_not_found", "node_id": "1", + "phase_id_not_found": "2", "network_id": "a096d627-72e1-4f9b-b129-951b1737bff4" }, { "type": "span_phase_reference_id_not_found", "span_id": "1", + "phase_id_not_found": "3", "network_id": "a096d627-72e1-4f9b-b129-951b1737bff4" }, { "type": "contract_related_phase_reference_id_not_found", "contract_id": "1", + "phase_id_not_found": "4", "network_id": "a096d627-72e1-4f9b-b129-951b1737bff4" } ] diff --git a/tests/fixtures/pythonvalidate/phase_id_not_found_1.input.json b/tests/fixtures/pythonvalidate/phase_id_not_found_1.input.json index 32c41ef..2d831e9 100644 --- a/tests/fixtures/pythonvalidate/phase_id_not_found_1.input.json +++ b/tests/fixtures/pythonvalidate/phase_id_not_found_1.input.json @@ -21,7 +21,7 @@ "id": "1", "name": "Accra to Kumasi", "phase": { - "id": "2" + "id": "3" }, "start": "1", "end": "2" @@ -40,7 +40,7 @@ "title": "NextGen Phase 1 Construction Contract", "relatedPhases": [ { - "id": "2" + "id": "4" } ] } diff --git a/tests/fixtures/pythonvalidate/phase_name_not_match_1.expected.json b/tests/fixtures/pythonvalidate/phase_name_not_match_1.expected.json index d8b9389..8e23b01 100644 --- a/tests/fixtures/pythonvalidate/phase_name_not_match_1.expected.json +++ b/tests/fixtures/pythonvalidate/phase_name_not_match_1.expected.json @@ -2,16 +2,19 @@ { "type": "node_phase_reference_name_does_not_match", "node_id": "1", + "name_in_reference": "I forget", "network_id": "a096d627-72e1-4f9b-b129-951b1737bff4" }, { "type": "span_phase_reference_name_does_not_match", "span_id": "1", + "name_in_reference": "I forget again", "network_id": "a096d627-72e1-4f9b-b129-951b1737bff4" }, { "type": "contract_related_phase_reference_name_does_not_match", "contract_id": "1", + "name_in_reference": "I forget, really I'm so bad", "network_id": "a096d627-72e1-4f9b-b129-951b1737bff4" } ] diff --git a/tests/fixtures/pythonvalidate/phase_name_not_match_1.input.json b/tests/fixtures/pythonvalidate/phase_name_not_match_1.input.json index 3e977da..c4d5a33 100644 --- a/tests/fixtures/pythonvalidate/phase_name_not_match_1.input.json +++ b/tests/fixtures/pythonvalidate/phase_name_not_match_1.input.json @@ -23,7 +23,7 @@ "name": "Accra to Kumasi", "phase": { "id": "1", - "name": "I forget" + "name": "I forget again" }, "start": "1", "end": "2" @@ -43,7 +43,7 @@ "relatedPhases": [ { "id": "1", - "name": "I forget" + "name": "I forget, really I'm so bad" } ] } diff --git a/tests/fixtures/pythonvalidate/phase_reference_name_set_but_not_in_original_1.expected.json b/tests/fixtures/pythonvalidate/phase_reference_name_set_but_not_in_original_1.expected.json index 15b365e..63cd341 100644 --- a/tests/fixtures/pythonvalidate/phase_reference_name_set_but_not_in_original_1.expected.json +++ b/tests/fixtures/pythonvalidate/phase_reference_name_set_but_not_in_original_1.expected.json @@ -2,21 +2,25 @@ { "type": "node_phase_reference_name_set_but_not_in_original", "node_id": "1", + "name_in_reference": "I forget", "network_id": "a096d627-72e1-4f9b-b129-951b1737bff4" }, { "type": "node_phase_reference_name_set_but_not_in_original", "node_id": "2", + "name_in_reference": "I forget again", "network_id": "a096d627-72e1-4f9b-b129-951b1737bff4" }, { "type": "span_phase_reference_name_set_but_not_in_original", "span_id": "1", + "name_in_reference": "I forget more", "network_id": "a096d627-72e1-4f9b-b129-951b1737bff4" }, { "type": "contract_related_phase_reference_name_set_but_not_in_original", "contract_id": "1", + "name_in_reference": "I forget, did I even know?", "network_id": "a096d627-72e1-4f9b-b129-951b1737bff4" } ] diff --git a/tests/fixtures/pythonvalidate/phase_reference_name_set_but_not_in_original_1.input.json b/tests/fixtures/pythonvalidate/phase_reference_name_set_but_not_in_original_1.input.json index a2af56b..f163123 100644 --- a/tests/fixtures/pythonvalidate/phase_reference_name_set_but_not_in_original_1.input.json +++ b/tests/fixtures/pythonvalidate/phase_reference_name_set_but_not_in_original_1.input.json @@ -17,7 +17,7 @@ "name": "Kumasi", "phase": { "id": "1", - "name": "I forget" + "name": "I forget again" } } ], @@ -27,7 +27,7 @@ "name": "Accra to Kumasi", "phase": { "id": "1", - "name": "I forget" + "name": "I forget more" }, "start": "1", "end": "2" @@ -45,7 +45,7 @@ "relatedPhases": [ { "id": "1", - "name": "I forget" + "name": "I forget, did I even know?" } ] } diff --git a/tests/fixtures/pythonvalidate/span_route_coordinates_incorrect_1.expected.json b/tests/fixtures/pythonvalidate/span_route_coordinates_incorrect_1.expected.json index efa9cc5..79221ff 100644 --- a/tests/fixtures/pythonvalidate/span_route_coordinates_incorrect_1.expected.json +++ b/tests/fixtures/pythonvalidate/span_route_coordinates_incorrect_1.expected.json @@ -2,6 +2,10 @@ { "type": "span_route_coordinates_incorrect", "span_id": "1", + "incorrect_coordinates": [ + -1.628, + 6.711 + ], "network_id": "a096d627-72e1-4f9b-b129-951b1737bff4" } ] diff --git a/tests/fixtures/pythonvalidate/span_route_type_incorrect_1.expected.json b/tests/fixtures/pythonvalidate/span_route_type_incorrect_1.expected.json index aa9ef37..25e585b 100644 --- a/tests/fixtures/pythonvalidate/span_route_type_incorrect_1.expected.json +++ b/tests/fixtures/pythonvalidate/span_route_type_incorrect_1.expected.json @@ -2,6 +2,7 @@ { "type": "span_route_type_incorrect", "span_id": "1", + "incorrect_type": "Point", "network_id": "a096d627-72e1-4f9b-b129-951b1737bff4" } ]