Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#769 Fixing bug when inspecting code-lists #771

Merged
merged 6 commits into from
Apr 3, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/csvcubed/cli/inspect/inspect.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,8 @@ def _generate_printables(
catalog_metadata_printable: str = metadata_printer.catalog_metadata_printable
column_component_info_printable: str = (
metadata_printer.column_component_info_printable
if csvw_type == CSVWType.QbDataSet
else ""
)
codelist_info_printable: str = (
metadata_printer.codelist_info_printable
Expand Down
23 changes: 21 additions & 2 deletions tests/behaviour/cli.feature
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ Feature: Test the csvcubed Command Line Interface.
And the file at "out/title-of-the-code-list.csv-metadata.json" should exist
And the file at "out/title-of-the-code-list.table.json" should exist
And the file at "out/validation-errors.json" should exist
And the csvcubed CLI should succeed
And the csvcubed build CLI should succeed
And the validation-errors.json file should contain
"""
"offending_value": "http://purl.org/dc/aboutdcmi#DCMI"
Expand Down Expand Up @@ -63,11 +63,30 @@ Feature: Test the csvcubed Command Line Interface.
Then the file at "testout/title-of-the-code-list.csv" should exist
And the file at "testout/title-of-the-code-list.csv-metadata.json" should exist
And the file at "testout/title-of-the-code-list.table.json" should exist
And the csvcubed CLI should succeed
And the csvcubed build CLI should succeed
Then remove test log files

Scenario: The csvcubed code-list build command will fail when there is a validation error.
Given the existing test-case file "readers/code-list-config/v1.0/code_list_config_produces_error.json"
When the csvcubed CLI is run with "code-list build readers/code-list-config/v1.0/code_list_config_produces_error.json --fail-when-validation-error"
Then the csvcubed CLI should fail with status code 1
Then remove test log files

Scenario: Test csvcubed inspect cube end-to-end
Given the existing test-case file "cli/inspect/multi-unit_multi-measure/alcohol-bulletin.csv-metadata.json"
And the existing test-case file "cli/inspect/multi-unit_multi-measure/alcohol-bulletin.csv"
And the existing test-case file "cli/inspect/multi-unit_multi-measure/alcohol-content.table.json"
And the existing test-case file "cli/inspect/multi-unit_multi-measure/alcohol-sub-type.table.json"
And the existing test-case file "cli/inspect/multi-unit_multi-measure/clearance-origin.table.json"
When the csvcubed CLI is run with "inspect cli/inspect/multi-unit_multi-measure/alcohol-bulletin.csv-metadata.json"
Then the csvcubed CLI should succeed
Then remove test log files


Scenario: Test csvcubed inspect code list end-to-end
Given the existing test-case file "cli/inspect/multi-unit_multi-measure/alcohol-content.csv-metadata.json"
And the existing test-case file "cli/inspect/multi-unit_multi-measure/alcohol-content.table.json"
And the existing test-case file "cli/inspect/multi-unit_multi-measure/alcohol-content.csv"
When the csvcubed CLI is run with "inspect cli/inspect/multi-unit_multi-measure/alcohol-content.csv-metadata.json"
Then the csvcubed CLI should succeed
Then remove test log files
9 changes: 7 additions & 2 deletions tests/behaviour/steps/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,19 @@ def step_impl(context, arguments: str):
context.csvcubed_log_location = Path(dirs.user_log_dir)


@then("the csvcubed CLI should succeed")
@then("the csvcubed build CLI should succeed")
def step_impl(context):
(status_code, response) = context.csvcubed_cli_result
assert status_code == 0, (status_code, response)
assert "Build Complete" in response, response


@then("the csvcubed CLI should succeed")
def step_impl(context):
(status_code, response) = context.csvcubed_cli_result
assert status_code == 0, (status_code, response)


@then("the csvcubed CLI should fail with status code {status_code}")
def step_impl(context, status_code: str):
(status_code, _) = context.csvcubed_cli_result
Expand Down Expand Up @@ -116,7 +122,6 @@ def run_command_in_temp_dir(context, command: str) -> Tuple[int, str]:
stderr_path = Path(tmp_dir_path / "buffer" / "stderr")

with open(stdout_path, "w") as stdout_file, open(stderr_path, "w") as stderr_file:

process = subprocess.Popen(
command,
shell=True,
Expand Down