diff --git a/CHANGELOG.md b/CHANGELOG.md index a80b05d..f19e6de 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,12 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. ## [Unreleased] +## [0.10.1] - 2021-09-22 + +### Fixed + +- A crash when statementID is not a string https://github.com/openownership/cove-bods/issues/67 + ## [0.10.0] - 2021-04-08 ### Changed diff --git a/libcovebods/lib/common_checks.py b/libcovebods/lib/common_checks.py index 3aaabc1..d673e3e 100644 --- a/libcovebods/lib/common_checks.py +++ b/libcovebods/lib/common_checks.py @@ -140,7 +140,7 @@ def run(self): count_replaces_statements_missing += 1 if replaces_statement_id in current_statement_ids: current_statement_ids.remove(replaces_statement_id) - if 'statementID' in statement: + if 'statementID' in statement and isinstance(statement['statementID'], str): statement_ids.add(statement['statementID']) # Return Results diff --git a/setup.py b/setup.py index 603ae09..4cc791c 100644 --- a/setup.py +++ b/setup.py @@ -2,7 +2,7 @@ setup( name='libcovebods', - version='0.10.0', + version='0.10.1', author='Open Data Services', author_email='code@opendataservices.coop', url='https://github.com/openownership/lib-cove-bods', diff --git a/tests/fixtures/0.2/bad_statement_id_type.json b/tests/fixtures/0.2/bad_statement_id_type.json new file mode 100644 index 0000000..895bbb8 --- /dev/null +++ b/tests/fixtures/0.2/bad_statement_id_type.json @@ -0,0 +1,24 @@ +[ + { + "statementID": {}, + "statementType": "entityStatement", + "isComponent": false, + "statementDate": "2017-11-18", + "entityType": "registeredEntity", + "name": "CHRINON LTD", + "foundingDate": "2010-11-18", + "identifiers": [ + { + "scheme": "GB-COH", + "id": "07444723" + } + ], + "publicationDetails": { + "publicationDate": "2018-02-13", + "bodsVersion": "0.2", + "publisher": { + "name": "CHRINON LTD" + } + } + } +] diff --git a/tests/test_api_0_2.py b/tests/test_api_0_2.py index 20450c6..6bdd6f2 100644 --- a/tests/test_api_0_2.py +++ b/tests/test_api_0_2.py @@ -1,3 +1,4 @@ +import json import tempfile import os from libcovebods.api import bods_json_output @@ -33,3 +34,20 @@ def test_iscompontent_os_03_dr_03(): assert results['validation_errors_count'] == 0 assert results['additional_fields_count'] == 0 assert results['additional_checks_count'] == 0 + + +def test_bad_statement_id_type(): + + cove_temp_folder = tempfile.mkdtemp(prefix='lib-cove-bods-tests-', dir=tempfile.gettempdir()) + json_filename = os.path.join(os.path.dirname( + os.path.realpath(__file__)), 'fixtures', '0.2', 'bad_statement_id_type.json' + ) + + results = bods_json_output(cove_temp_folder, json_filename) + + assert results['schema_version'] == '0.2' + assert results['validation_errors_count'] == 1 + validation_error = json.loads(results['validation_errors'][0][0]) + assert validation_error['message'].startswith("'statementID' should be a string.") + assert results['additional_fields_count'] == 0 + assert results['additional_checks_count'] == 0