Skip to content

Commit

Permalink
Report what version of the schema we checked against
Browse files Browse the repository at this point in the history
  • Loading branch information
jarofgreen committed Jun 27, 2019
1 parent f548707 commit 9ae63f5
Show file tree
Hide file tree
Showing 6 changed files with 8 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.

- Support for schema version 0.2.
If no meta information is in the data, 0.1 is assumed and work happens as before.
- Add new schema_version key for reporting https://github.com/openownership/lib-cove-bods/issues/28
- Statistic: Count of current ownership/control statements
- Statistic: Count of ownership-or-control statements by year
- Statistic: Count of subjects of ownership-or-control statements by year
Expand Down
2 changes: 2 additions & 0 deletions libcovebods/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ def bods_json_output(output_dir, file, file_type=None, json_data=None,

raise Exception("JSON only for now, sorry!")

context['schema_version'] = schema_bods.schema_version

context = context_api_transform(
common_checks_bods(context, output_dir, json_data, schema_bods, lib_cove_bods_config=lib_cove_bods_config)
)
Expand Down
1 change: 1 addition & 0 deletions libcovebods/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
# These details are used if the data does not specify a version
'schema_url': os.path.join(_schema_folder, 'schema-0-1-0.json'),
'schema_url_host': _schema_folder,
'schema_version': '0.1',
# But from 0.2 onwards, data should specify a version
'schema_versions': {
'0.2': {
Expand Down
2 changes: 2 additions & 0 deletions libcovebods/schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ def __init__(self, json_data=None, lib_cove_bods_config=None):
# The default schema we use ...
self.release_pkg_schema_url = lib_cove_bods_config.config['schema_url']
self.schema_host = lib_cove_bods_config.config['schema_url_host']
self.schema_version = lib_cove_bods_config.config['schema_version']
# ... unless the data specifies a version.
if isinstance(json_data, list) and len(json_data) > 0:
statement = json_data[0]
Expand All @@ -19,3 +20,4 @@ def __init__(self, json_data=None, lib_cove_bods_config=None):
if version in lib_cove_bods_config.config['schema_versions']:
self.release_pkg_schema_url = lib_cove_bods_config.config['schema_versions'][version]['schema_url']
self.schema_host = lib_cove_bods_config.config['schema_versions'][version]['schema_url_host']
self.schema_version = version
1 change: 1 addition & 0 deletions tests/test_api_0_1.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ def test_basic_1():

results = bods_json_output(cove_temp_folder, json_filename)

assert results['schema_version'] == '0.1'
assert results['validation_errors_count'] == 0
assert results['additional_fields_count'] == 0
assert results['additional_checks_count'] == 0
Expand Down
1 change: 1 addition & 0 deletions tests/test_api_0_2.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ def test_basic_1():

results = bods_json_output(cove_temp_folder, json_filename)

assert results['schema_version'] == '0.2'
assert results['validation_errors_count'] == 0
assert results['additional_fields_count'] == 0
assert results['additional_checks_count'] == 0

0 comments on commit 9ae63f5

Please sign in to comment.