def test_corner_cases_for_deprecated_data_fields(json_data): data = json.loads(json_data) schema = SchemaOCDS(release_data=data) json_data_paths = cove_common.get_json_data_generic_paths(data) deprecated_fields = cove_common.get_json_data_deprecated_fields(json_data_paths, schema) assert deprecated_fields['additionalIdentifiers']['explanation'][0] == '1.1' assert 'parties section at the top level of a release' in deprecated_fields['additionalIdentifiers']['explanation'][1] assert deprecated_fields['additionalIdentifiers']['paths'] == ('releases/buyer',) assert len(deprecated_fields.keys()) == 1 assert len(deprecated_fields['additionalIdentifiers']['paths']) == 1
def test_corner_cases_for_deprecated_data_fields(json_data): data = json.loads(json_data) schema = SchemaOCDS(release_data=data) json_data_paths = cove_common.get_json_data_generic_paths(data) deprecated_fields = cove_common.get_json_data_deprecated_fields( json_data_paths, schema) assert deprecated_fields["additionalIdentifiers"]["explanation"][ 0] == "1.1" assert ("parties section at the top level of a release" in deprecated_fields["additionalIdentifiers"]["explanation"][1]) assert deprecated_fields["additionalIdentifiers"]["paths"] == ( "releases/buyer", ) assert len(deprecated_fields.keys()) == 1 assert len(deprecated_fields["additionalIdentifiers"]["paths"]) == 1
def test_get_json_data_deprecated_fields(): with open( os.path.join( "tests", "fixtures", "tenders_releases_2_releases_with_deprecated_fields.json", )) as fp: json_data_w_deprecations = json.load(fp) schema_obj = SchemaOCDS() schema_obj.schema_host = os.path.join( "tests", "fixtures/") # "/" is for urljoin in lib-cove schema_obj.pkg_schema_name = ( "release_package_schema_ref_release_schema_deprecated_fields.json") schema_obj.pkg_schema_url = os.path.join(schema_obj.schema_host, schema_obj.pkg_schema_name) json_data_paths = cove_common.get_json_data_generic_paths( json_data_w_deprecations, generic_paths={}) deprecated_data_fields = cove_common.get_json_data_deprecated_fields( json_data_paths, schema_obj) expected_result = OrderedDict([ ( "initiationType", { "paths": ("releases/0", "releases/1"), "explanation": ( "1.1", "Not a useful field as always has to be tender", ), }, ), ( "quantity", { "paths": ("releases/0/tender/items/0", ), "explanation": ("1.1", "Nobody cares about quantities"), }, ), ]) for field_name in expected_result.keys(): assert field_name in deprecated_data_fields assert (expected_result[field_name]["paths"] == deprecated_data_fields[field_name]["paths"]) assert (expected_result[field_name]["explanation"] == deprecated_data_fields[field_name]["explanation"])
def test_get_json_data_deprecated_fields(): with open(os.path.join('cove_ocds', 'fixtures', 'tenders_releases_2_releases_with_deprecated_fields.json')) as fp: json_data_w_deprecations = json.load(fp) schema_obj = SchemaOCDS() schema_obj.schema_host = os.path.join('cove_ocds', 'fixtures/') schema_obj.release_pkg_schema_name = 'release_package_schema_ref_release_schema_deprecated_fields.json' schema_obj.release_pkg_schema_url = os.path.join(schema_obj.schema_host, schema_obj.release_pkg_schema_name) json_data_paths = cove_common.get_json_data_generic_paths(json_data_w_deprecations) deprecated_data_fields = cove_common.get_json_data_deprecated_fields(json_data_paths, schema_obj) expected_result = OrderedDict([ ('initiationType', {"paths": ('releases/0', 'releases/1'), "explanation": ('1.1', 'Not a useful field as always has to be tender')}), ('quantity', {"paths": ('releases/0/tender/items/0',), "explanation": ('1.1', 'Nobody cares about quantities')}) ]) for field_name in expected_result.keys(): assert field_name in deprecated_data_fields assert expected_result[field_name]["paths"] == deprecated_data_fields[field_name]["paths"] assert expected_result[field_name]["explanation"] == deprecated_data_fields[field_name]["explanation"]