Skip to content

Commit

Permalink
Merge pull request #65 from openownership/fix-null-stmtdate
Browse files Browse the repository at this point in the history
Catch error when statementDate is null
  • Loading branch information
rhiaro committed Jan 6, 2021
2 parents caf2fae + 1037a94 commit c73bb31
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 5 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Expand Up @@ -7,6 +7,12 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.

## [Unreleased]

## [0.8.1] - 2021-01-06

### Fixed

- Catch error when `statementDate` is `null`

## [0.8.0] - 2020-08-28

### Changed
Expand Down
2 changes: 1 addition & 1 deletion libcovebods/lib/common_checks.py
Expand Up @@ -102,7 +102,7 @@ def run(self):
elif statement_type == 'ownershipOrControlStatement':
try:
year = int(statement.get('statementDate', '').split('-')[0])
except ValueError:
except (ValueError, AttributeError):
year = None
count_ownership_or_control_statement += 1
interested_party = statement.get('interestedParty')
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Expand Up @@ -2,7 +2,7 @@

setup(
name='libcovebods',
version='0.8.0',
version='0.8.1',
author='Open Data Services',
author_email='code@opendataservices.coop',
url='https://github.com/openownership/lib-cove-bods',
Expand Down
6 changes: 6 additions & 0 deletions tests/fixtures/0.1/bad_statement_date.json
Expand Up @@ -5,6 +5,12 @@
"statementType": "ownershipOrControlStatement",
"statementDate": "bad"
},
{
"subject": {"describedByEntityStatement": "1dc0e987-5c57-4a1c-b3ad-61353b66a9b7"},
"interestedParty": {"describedByPersonStatement": "019a93f1-e470-42e9-957b-03559861b2e2"},
"statementType": "ownershipOrControlStatement",
"statementDate": null
},
{
"subject": {"describedByEntityStatement": "f0466727-fa1b-4bbf-b723-aafc1ef8922e"},
"interestedParty": {"describedByPersonStatement": "9b9cd535-8c23-48a1-82dc-3303cd9d8bff"},
Expand Down
6 changes: 3 additions & 3 deletions tests/test_api_0_1.py
Expand Up @@ -1018,15 +1018,15 @@ def test_bad_statement_date():

results = bods_json_output(cove_temp_folder, json_filename)
assert results['statistics']['count_ownership_or_control_statement_by_year'] == {
None: 1,
None: 2,
2011: 1
}
assert results['statistics']['count_ownership_or_control_statement_subject_by_year'] == {
None: 1,
None: 2,
2011: 1
}
assert results['statistics']['count_ownership_or_control_statement_interested_party_with_person_by_year'] == {
None: 1,
None: 2,
2011: 1
}
assert results['statistics']['count_ownership_or_control_statement_interested_party_with_entity_by_year'] == {
Expand Down

0 comments on commit c73bb31

Please sign in to comment.