From d6e80ff0aabeff805f3c946d85127cb3534d7e6f Mon Sep 17 00:00:00 2001 From: "Ed (ODSC)" Date: Sun, 22 Sep 2024 17:56:31 +0100 Subject: [PATCH] libcovebods: Improve code formating --- libcovebods/jsonschemavalidate.py | 5 +- libcovebods/schema.py | 2 +- libcovebods/schema_dir.py | 5 +- libcovebods/tasks/checks.py | 88 +++++++++---------- libcovebods/tasks/statistics.py | 51 +++++++---- libcovebods/utils.py | 3 +- pyproject.toml | 1 + tests/test_additional_checks_0_4_0.py | 7 +- tests/test_api_0_1.py | 3 +- tests/test_lib_common.py | 2 +- tests/test_schema_validation_0_4.py | 9 +- tests/test_stat_count_declaration_subjects.py | 1 + ...l_statement_interest_direct_or_indirect.py | 3 +- ...trol_statement_interest_statement_types.py | 13 ++- 14 files changed, 110 insertions(+), 83 deletions(-) diff --git a/libcovebods/jsonschemavalidate.py b/libcovebods/jsonschemavalidate.py index c956a41..a664f68 100644 --- a/libcovebods/jsonschemavalidate.py +++ b/libcovebods/jsonschemavalidate.py @@ -3,8 +3,7 @@ from jsonschema import FormatChecker from jsonschema.exceptions import ValidationError -from jsonschema.validators import Draft4Validator -from jsonschema.validators import Draft202012Validator +from jsonschema.validators import Draft4Validator, Draft202012Validator import libcovebods.data_reader from libcovebods.schema import SchemaBODS @@ -157,7 +156,7 @@ def json(self): path_ending = self._path[-1] if isinstance(self._path[-1], int) and len(self._path) >= 2: # We're dealing with elements in an array of items at this point - path_ending = "{}/[number]".format(self._path[-2]) + path_ending = f"{self._path[-2]}/[number]" elif isinstance(self._path[0], int) and len(self._path) == 1: path_ending = "[number]" else: diff --git a/libcovebods/schema.py b/libcovebods/schema.py index 96aad4c..7754f56 100644 --- a/libcovebods/schema.py +++ b/libcovebods/schema.py @@ -7,7 +7,7 @@ import libcovebods.data_reader from libcovebods.config import LibCoveBODSConfig -from libcovebods.schema_dir import schema_registry, get_scheme_file_data +from libcovebods.schema_dir import get_scheme_file_data, schema_registry try: from functools import cached_property diff --git a/libcovebods/schema_dir.py b/libcovebods/schema_dir.py index 42646f0..e17517a 100644 --- a/libcovebods/schema_dir.py +++ b/libcovebods/schema_dir.py @@ -1,7 +1,8 @@ import json from pathlib import Path -from jscc.schema import is_json_schema, is_codelist, is_missing_property -from jscc.testing.filesystem import walk_json_data, walk_csv_data + +from jscc.schema import is_json_schema +from jscc.testing.filesystem import walk_json_data from referencing import Registry, Resource from referencing.jsonschema import DRAFT202012 diff --git a/libcovebods/tasks/checks.py b/libcovebods/tasks/checks.py index c08d58f..913e509 100644 --- a/libcovebods/tasks/checks.py +++ b/libcovebods/tasks/checks.py @@ -1,14 +1,17 @@ -import pycountry - from collections import defaultdict -from datetime import datetime, timedelta -from jsonpointer import resolve_pointer +from datetime import datetime +import jsonpointer +import pycountry from libcove2.common import get_orgids_prefixes # type: ignore from libcovebods.base_task import AdditionalCheck -from libcovebods.utils import (get_year_from_bods_birthdate_or_deathdate, - parse_date_field, numeric_value, sort_by_date) +from libcovebods.utils import ( + get_year_from_bods_birthdate_or_deathdate, + numeric_value, + parse_date_field, + sort_by_date, +) class LegacyChecks(AdditionalCheck): @@ -37,7 +40,8 @@ def __init__(self, lib_cove_bods_config, schema_object): self.orgids_prefixes = get_orgids_prefixes() def check_entity_statement_first_pass(self, statement): - # Not doing any work if no statementID preserves the old behaviour of the code, but this should be evaluated. + # Not doing any work if no statementID preserves the old behaviour of the code, + # but this should be evaluated. if not statement.get("statementID"): return identifiers = statement.get("identifiers") @@ -47,7 +51,7 @@ def check_entity_statement_first_pass(self, statement): if ( "scheme" in identifier and identifier["scheme"] - and not identifier["scheme"] in self.orgids_prefixes + and identifier["scheme"] not in self.orgids_prefixes ): self._additional_check_results.append( { @@ -90,7 +94,8 @@ def check_entity_statement_first_pass(self, statement): ) def check_person_statement_first_pass(self, statement): - # Not doing any work if no statementID preserves the old behaviour of the code, but this should be evaluated. + # Not doing any work if no statementID preserves the old behaviour of the code, + # but this should be evaluated. if not statement.get("statementID"): return if "birthDate" in statement: @@ -158,7 +163,8 @@ def check_person_statement_first_pass(self, statement): ) def check_ownership_or_control_statement_first_pass(self, statement): - # Not doing any work if no statementID preserves the old behaviour of the code, but this should be evaluated. + # Not doing any work if no statementID preserves the old behaviour of the code, + # but this should be evaluated. if not statement.get("statementID"): return ( @@ -277,7 +283,8 @@ def __init__(self, lib_cove_bods_config, schema_object): self.statement_ids_counted = {} def check_entity_statement_first_pass(self, statement): - # Not doing any work if no statementID preserves the old behaviour of the code, but this should be evaluated. + # Not doing any work if no statementID preserves the old behaviour of the code, + # but this should be evaluated. if not statement.get("statementID"): return self.entity_statements_seen.append(statement.get("statementID")) @@ -297,13 +304,15 @@ def check_entity_statement_first_pass(self, statement): ) def check_person_statement_first_pass(self, statement): - # Not doing any work if no statementID preserves the old behaviour of the code, but this should be evaluated. + # Not doing any work if no statementID preserves the old behaviour of the code, + # but this should be evaluated. if not statement.get("statementID"): return self.person_statements_seen.append(statement.get("statementID")) def check_ownership_or_control_statement_first_pass(self, statement): - # Not doing any work if no statementID preserves the old behaviour of the code, but this should be evaluated. + # Not doing any work if no statementID preserves the old behaviour of the code, + # but this should be evaluated. if not statement.get("statementID"): return self.ownership_or_control_statements_seen.append(statement.get("statementID")) @@ -398,7 +407,8 @@ def check_ownership_or_control_statement_first_pass(self, statement): ) def check_entity_statement_second_pass(self, statement): - # Not doing any work if no statementID preserves the old behaviour of the code, but this should be evaluated. + # Not doing any work if no statementID preserves the old behaviour of the code, + # but this should be evaluated. if not statement.get("statementID"): return if ( @@ -427,7 +437,8 @@ def check_entity_statement_second_pass(self, statement): ) def check_person_statement_second_pass(self, statement): - # Not doing any work if no statementID preserves the old behaviour of the code, but this should be evaluated. + # Not doing any work if no statementID preserves the old behaviour of the code, + # but this should be evaluated. if not statement.get("statementID"): return if ( @@ -456,7 +467,8 @@ def check_person_statement_second_pass(self, statement): ) def check_ownership_or_control_statement_second_pass(self, statement): - # Not doing any work if no statementID preserves the old behaviour of the code, but this should be evaluated. + # Not doing any work if no statementID preserves the old behaviour of the code, + # but this should be evaluated. if not statement.get("statementID"): return interested_party = statement.get("interestedParty") @@ -857,7 +869,7 @@ def does_apply_to_schema(lib_cove_bods_config, schema_object) -> bool: def check_statement_first_pass(self, statement): if ("publicationDetails" in statement and isinstance(statement["publicationDetails"], dict) - and "publicationDate" in statement["publicationDetails"] and + and "publicationDate" in statement["publicationDetails"] and statement["publicationDetails"]["publicationDate"]): publication_date = parse_date_field(statement["publicationDetails"]["publicationDate"]) if publication_date and publication_date > datetime.now().date(): @@ -1094,7 +1106,7 @@ def check_statement_first_pass(self, statement): def check_statement_second_pass(self, statement): if "declarationSubject" in statement: - if not statement["declarationSubject"] in self._statements: + if statement["declarationSubject"] not in self._statements: self._additional_check_results.append( { "type": "statement_declaration_subject_not_exist", @@ -1103,7 +1115,7 @@ def check_statement_second_pass(self, statement): }) else: for record_type in self._statements[statement["declarationSubject"]]: - if not record_type in ('entity', 'person'): + if record_type not in ('entity', 'person'): self._additional_check_results.append( { "type": "statement_declaration_subject_not_entity_person", @@ -1135,20 +1147,11 @@ def check_statement_first_pass(self, statement): self._components[component_id] = statement["recordId"] def check_statement_second_pass(self, statement): - print("Boo!") if ("recordId" in statement and "recordDetails" in statement and isinstance(statement["recordDetails"], dict) and "isComponent" in statement["recordDetails"]): - print(statement["recordId"], statement["recordDetails"]["isComponent"], self._statements, - self._components) if statement["recordDetails"]["isComponent"] is True: - #print(statement["recordId"] in self._statements, self._statements[statement["recordId"]], - # self._statements[self._components[statement["recordId"]]]) - print("iscomponent:", statement["recordId"], self._statements) - if not statement["recordId"] in self._components or not (self._statements[statement["recordId"]] + if statement["recordId"] not in self._components or not (self._statements[statement["recordId"]] < self._statements[self._components[statement["recordId"]]]): - #print("Failed:", statement["recordId"], self._components, - # self._statements[statement["recordId"]], self._statements[self._components[statement["recordId"]]]) - print("Failed:", statement["recordId"], self._components) self._additional_check_results.append( { "type": "statement_entity_is_component_not_in_component_details", @@ -1212,7 +1215,6 @@ def final_checks(self): sorted_series = sort_by_date(self._series[series], 0) statuses = [s[1] for s in sorted_series] types = [s[2] for s in sorted_series] - print(series, statuses, types) if len([s for s in statuses if s == 'new']) > 1: self._additional_check_results.append( { @@ -1270,7 +1272,7 @@ def check_ownership_or_control_statement_second_pass(self, statement): if ("componentRecords" in statement["recordDetails"] and isinstance(statement["recordDetails"]["componentRecords"], list)): for component in statement["recordDetails"]["componentRecords"]: - if not component in self._records: + if component not in self._records: if component in self._statements: self._additional_check_results.append( { @@ -1304,7 +1306,7 @@ def check_ownership_or_control_statement_second_pass(self, statement): if "recordDetails" in statement and isinstance(statement["recordDetails"], dict): if ("subject" in statement["recordDetails"] and isinstance(statement["recordDetails"]["subject"], str)): - if not statement["recordDetails"]["subject"] in self._records: + if statement["recordDetails"]["subject"] not in self._records: self._additional_check_results.append( { "type": "subject_must_be_record_id", @@ -1320,14 +1322,14 @@ def check_ownership_or_control_statement_second_pass(self, statement): }) if ("interestedParty" in statement["recordDetails"] and isinstance(statement["recordDetails"]["interestedParty"], str)): - if not statement["recordDetails"]["interestedParty"] in self._records: + if statement["recordDetails"]["interestedParty"] not in self._records: self._additional_check_results.append( { "type": "interested_party_must_be_record_id", "statement_type": None, "statement": statement.get("statementId"), }) - elif not self._records[statement["recordDetails"]["interestedParty"]] in ('entity', 'person'): + elif self._records[statement["recordDetails"]["interestedParty"]] not in ('entity', 'person'): self._additional_check_results.append( { "type": "interested_party_can_only_refer_to_entity_or_person", @@ -1362,10 +1364,8 @@ def check_entity_statement_first_pass(self, statement): for annotation in statement["annotations"]: if "statementPointerTarget" in annotation: try: - resolve_pointer(statement, annotation["statementPointerTarget"]) - #print("Pointer check:", resolve_pointer(statement, statement["annotations"]["statementPointerTarget"]), - # statement, statement["annotations"]["statementPointerTarget"]) - except: + jsonpointer.resolve_pointer(statement, annotation["statementPointerTarget"]) + except (jsonpointer.JsonPointerException, TypeError): self._additional_check_results.append( { "type": "annotation_statement_pointer_target_invalid", @@ -1420,8 +1420,8 @@ def check_ownership_or_control_statement_second_pass(self, statement): entity_type = self._records[statement["recordDetails"]["subject"]][1] print("Entity type:", entity_type) if (not entity_type or not isinstance(statement["recordDetails"], dict) or - not "type" in entity_type or not entity_type["type"] == 'arrangement' or - not "subtype" in entity_type or not entity_type["subtype"] == 'nomination'): + "type" not in entity_type or not entity_type["type"] == 'arrangement' or + "subtype" not in entity_type or not entity_type["subtype"] == 'nomination'): self._additional_check_results.append( { "type": "relationship_interests_subject_should_be_entity_nomination_arrangement", @@ -1444,7 +1444,7 @@ def check_ownership_or_control_statement_second_pass(self, statement): entity_type = self._records[statement["recordDetails"]["subject"]][1] print("Entity type:", entity_type) if (not entity_type or not isinstance(statement["recordDetails"], dict) or - not "subtype" in entity_type or not entity_type["subtype"] == 'trust'): + "subtype" not in entity_type or not entity_type["subtype"] == 'trust'): self._additional_check_results.append( { "type": "relationship_interests_subject_should_be_entity_trust", @@ -1466,7 +1466,7 @@ def does_apply_to_schema(lib_cove_bods_config, schema_object) -> bool: def check_statement_first_pass(self, statement): if "recordId" in statement: self._count += 1 - if not statement["recordId"] in self._records: + if statement["recordId"] not in self._records: self._records[statement["recordId"]] = self._count def check_ownership_or_control_statement_second_pass(self, statement): @@ -1530,14 +1530,14 @@ def check_person_statement_first_pass(self, statement): "UNO", "XBA", "XIM", "XCC", "XCO", "XEC", "XPO", "XOM", "XXA", "XXB", "XXC", "XXX", "ZIM") if (not pycountry.countries.get(alpha_3=identifier["scheme"].split("-")[0]) and - not identifier["scheme"].split("-")[0] in other_codes): + identifier["scheme"].split("-")[0] not in other_codes): self._additional_check_results.append( { "type": "person_identifiers_no_valid_iso_3166_1_alpha_3_code", "statement_type": None, "statement": statement.get("statementId"), }) - elif not identifier["scheme"].split("-")[1] in ('PASSPORT', 'TAXID', 'IDCARD'): + elif identifier["scheme"].split("-")[1] not in ('PASSPORT', 'TAXID', 'IDCARD'): self._additional_check_results.append( { "type": "person_identifiers_not_passport_taxid_idcard", diff --git a/libcovebods/tasks/statistics.py b/libcovebods/tasks/statistics.py index d7b2a53..9e6cc48 100644 --- a/libcovebods/tasks/statistics.py +++ b/libcovebods/tasks/statistics.py @@ -61,8 +61,10 @@ def get_statistics(self): data = { "count_entity_statements": self.count_entity_statements, "count_entity_statements_types": self.count_entity_statements_types, - "count_entity_statements_types_with_any_identifier": self.count_entity_statements_types_with_any_identifier, - "count_entity_statements_types_with_any_identifier_with_id_and_scheme": self.count_entity_statements_types_with_any_identifier_with_id_and_scheme, + "count_entity_statements_types_with_any_identifier": + self.count_entity_statements_types_with_any_identifier, + "count_entity_statements_types_with_any_identifier_with_id_and_scheme": + self.count_entity_statements_types_with_any_identifier_with_id_and_scheme, } return data @@ -125,8 +127,10 @@ def get_statistics(self): data = { "count_entity_statements": self.count_entity_statements, "count_entity_statements_types": self.count_entity_statements_types, - "count_entity_statements_types_with_any_identifier": self.count_entity_statements_types_with_any_identifier, - "count_entity_statements_types_with_any_identifier_with_id_and_scheme": self.count_entity_statements_types_with_any_identifier_with_id_and_scheme, + "count_entity_statements_types_with_any_identifier": + self.count_entity_statements_types_with_any_identifier, + "count_entity_statements_types_with_any_identifier_with_id_and_scheme": + self.count_entity_statements_types_with_any_identifier_with_id_and_scheme, } return data @@ -281,18 +285,25 @@ def check_ownership_or_control_statement_first_pass(self, statement): def get_statistics(self): data = { "count_ownership_or_control_statement": self.count_ownership_or_control_statement, - "count_ownership_or_control_statement_interested_party_with_person": self.count_ownership_or_control_statement_interested_party_with_person, - "count_ownership_or_control_statement_interested_party_with_entity": self.count_ownership_or_control_statement_interested_party_with_entity, - "count_ownership_or_control_statement_interested_party_with_unspecified": self.count_ownership_or_control_statement_interested_party_with_unspecified, - "count_ownership_or_control_statement_interest_statement_types": self.count_ownership_or_control_statement_interest_statement_types, + "count_ownership_or_control_statement_interested_party_with_person": + self.count_ownership_or_control_statement_interested_party_with_person, + "count_ownership_or_control_statement_interested_party_with_entity": + self.count_ownership_or_control_statement_interested_party_with_entity, + "count_ownership_or_control_statement_interested_party_with_unspecified": + self.count_ownership_or_control_statement_interested_party_with_unspecified, + "count_ownership_or_control_statement_interest_statement_types": + self.count_ownership_or_control_statement_interest_statement_types, "count_ownership_or_control_statement_by_year": self.count_ownership_or_control_statement_by_year, "count_ownership_or_control_statement_subject_by_year": { year: len(year_set) for year, year_set in self.subject_statement_ids_by_year.items() }, - "count_ownership_or_control_statement_interested_party_with_entity_by_year": self.count_ownership_or_control_statement_interested_party_with_entity_by_year, - "count_ownership_or_control_statement_interested_party_with_person_by_year": self.count_ownership_or_control_statement_interested_party_with_person_by_year, - "count_ownership_or_control_statement_interested_party_with_unspecified_by_year": self.count_ownership_or_control_statement_interested_party_with_unspecified_by_year, + "count_ownership_or_control_statement_interested_party_with_entity_by_year": + self.count_ownership_or_control_statement_interested_party_with_entity_by_year, + "count_ownership_or_control_statement_interested_party_with_person_by_year": + self.count_ownership_or_control_statement_interested_party_with_person_by_year, + "count_ownership_or_control_statement_interested_party_with_unspecified_by_year": + self.count_ownership_or_control_statement_interested_party_with_unspecified_by_year, } return data @@ -353,14 +364,18 @@ def check_ownership_or_control_statement_first_pass(self, statement): def get_statistics(self): data = { "count_ownership_or_control_statement": self.count_ownership_or_control_statement, - "count_ownership_or_control_statement_interested_party": self.count_ownership_or_control_statement_interested_party, - "count_ownership_or_control_statement_interest_statement_types": self.count_ownership_or_control_statement_interest_statement_types, - "count_ownership_or_control_statement_by_year": self.count_ownership_or_control_statement_by_year, + "count_ownership_or_control_statement_interested_party": + self.count_ownership_or_control_statement_interested_party, + "count_ownership_or_control_statement_interest_statement_types": + self.count_ownership_or_control_statement_interest_statement_types, + "count_ownership_or_control_statement_by_year": + self.count_ownership_or_control_statement_by_year, "count_ownership_or_control_statement_subject_by_year": { year: len(year_set) for year, year_set in self.subject_statement_ids_by_year.items() }, - "count_ownership_or_control_statement_interested_party_by_year": self.count_ownership_or_control_statement_interested_party_by_year, + "count_ownership_or_control_statement_interested_party_by_year": + self.count_ownership_or_control_statement_interested_party_by_year, } return data @@ -447,7 +462,8 @@ def get_statistics(self): "count_addresses": self.count_addresses, "count_addresses_with_postcode": self.count_addresses_with_postcode, "count_addresses_with_country": self.count_addresses_with_country, - "count_addresses_with_postcode_duplicated_in_address": self.count_addresses_with_postcode_duplicated_in_address, + "count_addresses_with_postcode_duplicated_in_address": + self.count_addresses_with_postcode_duplicated_in_address, } return data @@ -485,7 +501,8 @@ def check_ownership_or_control_statement_first_pass(self, statement): def get_statistics(self): return { - "count_ownership_or_control_statement_interest_direct_or_indirect": self.count_ownership_or_control_statement_interest_direct_or_indirect, + "count_ownership_or_control_statement_interest_direct_or_indirect": + self.count_ownership_or_control_statement_interest_direct_or_indirect, } diff --git a/libcovebods/utils.py b/libcovebods/utils.py index 1c02ae5..fae6c86 100644 --- a/libcovebods/utils.py +++ b/libcovebods/utils.py @@ -1,5 +1,4 @@ import datetime -import json import re from dateutil import parser @@ -58,7 +57,7 @@ def numeric_value(value): try: float(value) return True - except: + except ValueError: return False def sort_by_date(list_with_date, index): diff --git a/pyproject.toml b/pyproject.toml index 4b867fc..2357282 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -8,3 +8,4 @@ lint.select = [ "C4", # flake8-comprehensions "UP", # pyupgrade ] +line-length = 140 diff --git a/tests/test_additional_checks_0_4_0.py b/tests/test_additional_checks_0_4_0.py index 5e1a66c..fa32a5c 100644 --- a/tests/test_additional_checks_0_4_0.py +++ b/tests/test_additional_checks_0_4_0.py @@ -3,6 +3,7 @@ from tests.api import bods_json_output + def test_retrievedat_not_future_date_invalid_1(): cove_temp_folder = tempfile.mkdtemp( @@ -1336,7 +1337,7 @@ def test_statement_series_valid_2(): assert results["additional_fields_count"] == 0 assert results["additional_checks_count"] == 0 -def test_statement_series_invalid_1(): +def test_statement_relationship_component_records_are_record_ids_invalid_1(): cove_temp_folder = tempfile.mkdtemp( prefix="lib-cove-bods-tests-", dir=tempfile.gettempdir() @@ -1358,7 +1359,7 @@ def test_statement_series_invalid_1(): assert results["additional_fields_count"] == 0 assert results["additional_checks_count"] == 1 -def test_statement_series_invalid_2(): +def test_statement_relationship_component_records_are_record_ids_invalid_2(): cove_temp_folder = tempfile.mkdtemp( prefix="lib-cove-bods-tests-", dir=tempfile.gettempdir() @@ -1380,7 +1381,7 @@ def test_statement_series_invalid_2(): assert results["additional_fields_count"] == 0 assert results["additional_checks_count"] == 1 -def test_statement_series_valid_1(): +def test_statement_relationship_component_records_are_record_ids_valid_1(): cove_temp_folder = tempfile.mkdtemp( prefix="lib-cove-bods-tests-", dir=tempfile.gettempdir() diff --git a/tests/test_api_0_1.py b/tests/test_api_0_1.py index e689ced..f23adad 100644 --- a/tests/test_api_0_1.py +++ b/tests/test_api_0_1.py @@ -1239,7 +1239,8 @@ def test_badfile_all_validation_errors(): "badfile_all_validation_errors.json", ) # This file is generated with - # libcovebods jsv tests/fixtures/0.1/badfile_all_validation_errors.json > tests/fixtures/0.1/badfile_all_validation_errors.expected.json + # libcovebods jsv tests/fixtures/0.1/badfile_all_validation_errors.json > + # tests/fixtures/0.1/badfile_all_validation_errors.expected.json expected_json_filename = os.path.join( os.path.dirname(os.path.realpath(__file__)), "fixtures", diff --git a/tests/test_lib_common.py b/tests/test_lib_common.py index fd6f996..49d75ee 100644 --- a/tests/test_lib_common.py +++ b/tests/test_lib_common.py @@ -72,7 +72,7 @@ def test_this_YYYY(self): def test_this_YYYY_MM(self): today = dateutil.utils.today(UTC) assert ( - is_interest_current({"endDate": "{}-{}".format(today.year, today.month)}) + is_interest_current({"endDate": f"{today.year}-{today.month}"}) is True ) diff --git a/tests/test_schema_validation_0_4.py b/tests/test_schema_validation_0_4.py index ab7adbc..9694015 100644 --- a/tests/test_schema_validation_0_4.py +++ b/tests/test_schema_validation_0_4.py @@ -1,12 +1,13 @@ -import json import csv import os import pathlib -import pytest import tempfile +import pytest + from tests.api import bods_json_output + @pytest.fixture def expected_errors(): expected = [] @@ -29,7 +30,8 @@ def extract_elements(element_path): out.append(0) else: out.append(elem) - if len(out) == 1 and out[0] == '$': out = [] + if (len(out) == 1 and out[0] == '$'): + out = [] return out def test_all_schema_validation_invalid(expected_errors): @@ -62,7 +64,6 @@ def test_all_schema_validation_invalid(expected_errors): else: print(expected) print(results['validation_errors'][0]) - assert False def test_all_schema_validation_valid(valid_statements): diff --git a/tests/test_stat_count_declaration_subjects.py b/tests/test_stat_count_declaration_subjects.py index 7fccfd4..626c38f 100644 --- a/tests/test_stat_count_declaration_subjects.py +++ b/tests/test_stat_count_declaration_subjects.py @@ -3,6 +3,7 @@ from tests.api import bods_json_output + def test_schema_0_4_count(): cove_temp_folder = tempfile.mkdtemp( diff --git a/tests/test_stat_count_ownership_or_control_statement_interest_direct_or_indirect.py b/tests/test_stat_count_ownership_or_control_statement_interest_direct_or_indirect.py index e314670..40a6d25 100644 --- a/tests/test_stat_count_ownership_or_control_statement_interest_direct_or_indirect.py +++ b/tests/test_stat_count_ownership_or_control_statement_interest_direct_or_indirect.py @@ -38,7 +38,8 @@ def test_schema_0_3_basic_1(): assert results["schema_version"] == "0.3" # We want to test the dict has the correct keys! - # So these tests are deliberately written so they will error if the specified key is not in that dict + # So these tests are deliberately written so they will error if the specified key + # is not in that dict assert ( 1 == results["statistics"][ diff --git a/tests/test_stat_count_ownership_or_control_statement_interest_statement_types.py b/tests/test_stat_count_ownership_or_control_statement_interest_statement_types.py index 67023fe..9bd5e87 100644 --- a/tests/test_stat_count_ownership_or_control_statement_interest_statement_types.py +++ b/tests/test_stat_count_ownership_or_control_statement_interest_statement_types.py @@ -17,14 +17,16 @@ def test_schema_0_1(): assert results["schema_version"] == "0.1" - # Schema v0.1 and Schema v0.2 have different enum options, make sure that is reflected in data + # Schema v0.1 and Schema v0.2 have different enum options, make sure that + # is reflected in data keys = results["statistics"][ "count_ownership_or_control_statement_interest_statement_types" ].keys() assert 12 == len(keys) # We want to test the dict has the correct keys! - # So these tests are deliberately written so they will error if the specified key is not in that dict + # So these tests are deliberately written so they will error if the specified + # key is not in that dict assert ( 1 == results["statistics"][ @@ -112,14 +114,16 @@ def test_schema_0_2(): assert results["schema_version"] == "0.2" - # Schema v0.1 and Schema v0.2 have different enum options, make sure that is reflected in data + # Schema v0.1 and Schema v0.2 have different enum options, make sure that + # is reflected in data keys = results["statistics"][ "count_ownership_or_control_statement_interest_statement_types" ].keys() assert 14 == len(keys) # We want to test the dict has the correct keys! - # So these tests are deliberately written so they will error if the specified key is not in that dict + # So these tests are deliberately written so they will error if the specified key + # is not in that dict assert ( 1 == results["statistics"][ @@ -204,3 +208,4 @@ def test_schema_0_2(): "count_ownership_or_control_statement_interest_statement_types" ]["conditional-rights-granted-by-contract"] ) # noqa +