Skip to content

Commit

Permalink
merge conflict
Browse files Browse the repository at this point in the history
  • Loading branch information
yibeichan committed Jan 8, 2024
2 parents 559e4f5 + 8bdb8ec commit 42314d9
Showing 1 changed file with 14 additions and 6 deletions.
20 changes: 14 additions & 6 deletions reproschema/tests/test_reproschema2redcap.py
Original file line number Diff line number Diff line change
@@ -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:")
Expand All @@ -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
assert len(csv_contents) > 0

0 comments on commit 42314d9

Please sign in to comment.