From 8bdb8ec97fd386ad6d1f6464518bb5b4f5a4726d Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 8 Jan 2024 20:12:23 +0000 Subject: [PATCH] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- reproschema/cli.py | 4 +++- reproschema/tests/test_reproschema2redcap.py | 20 ++++++++++++++------ 2 files changed, 17 insertions(+), 7 deletions(-) diff --git a/reproschema/cli.py b/reproschema/cli.py index 30bb939..edd1657 100644 --- a/reproschema/cli.py +++ b/reproschema/cli.py @@ -124,4 +124,6 @@ def reproschema2redcap(input_path, output_csv_path): # Convert input_path to a Path object input_path_obj = Path(input_path) rs2redcap(input_path_obj, output_csv_path) - click.echo(f"Converted reproschema JSON from {input_path} to Redcap CSV at {output_csv_path}") \ No newline at end of file + click.echo( + f"Converted reproschema JSON from {input_path} to Redcap CSV at {output_csv_path}" + ) diff --git a/reproschema/tests/test_reproschema2redcap.py b/reproschema/tests/test_reproschema2redcap.py index 374d8b7..f8438ac 100644 --- a/reproschema/tests/test_reproschema2redcap.py +++ b/reproschema/tests/test_reproschema2redcap.py @@ -1,37 +1,45 @@ import os import pytest from click.testing import CliRunner -from ..cli import main +from ..cli import main from shutil import copytree from pathlib import Path import csv + def test_reproschema2redcap_success(): runner = CliRunner() with runner.isolated_filesystem(): # Copy necessary test data into the isolated filesystem - original_data_dir = os.path.join(os.path.dirname(__file__), "test_rs2redcap_data") + original_data_dir = os.path.join( + os.path.dirname(__file__), "test_rs2redcap_data" + ) copytree(original_data_dir, "input_data") input_path = Path("input_data") # Using Path object output_csv_path = "output.csv" # Invoke the reproschema2redcap command - result = runner.invoke(main, ['reproschema2redcap', str(input_path), output_csv_path]) + result = runner.invoke( + main, ["reproschema2redcap", str(input_path), output_csv_path] + ) # Print the output for debugging print(result.output) # Assert the expected outcomes assert result.exit_code == 0 - assert f"Converted reproschema JSON from {input_path} to Redcap CSV at {output_csv_path}" in result.output + assert ( + f"Converted reproschema JSON from {input_path} to Redcap CSV at {output_csv_path}" + in result.output + ) # Check if the output CSV file has been created assert os.path.exists(output_csv_path) # Read and print the contents of the CSV file - with open(output_csv_path, 'r', encoding='utf-8') as csv_file: + with open(output_csv_path, "r", encoding="utf-8") as csv_file: reader = csv.reader(csv_file) csv_contents = list(reader) print("CSV File Contents:") @@ -40,4 +48,4 @@ def test_reproschema2redcap_success(): # Optionally, assert conditions about the CSV contents # For example, assert that the file is not empty - assert len(csv_contents) > 0 \ No newline at end of file + assert len(csv_contents) > 0