Skip to content
Snippets Groups Projects
Commit fe203762 authored by Eva Bardou's avatar Eva Bardou :frog:
Browse files

Suggestion + Fixes

parent 27f0aadf
No related branches found
No related tags found
1 merge request!38Use csv.DictReader rather than csv.reader
Pipeline #150441 passed
......@@ -350,7 +350,10 @@ def run_multiple(file_csv: Path, folder: Path, threshold: int, verbose: bool):
"""Run the program for multiple files (correlation indicated in the csv file)"""
# Read the csv in a list
with file_csv.open() as read_obj:
csv_reader = csv.DictReader(read_obj, fieldnames=CSV_HEADER)
csv_reader = csv.DictReader(read_obj)
assert (
csv_reader.fieldnames == CSV_HEADER
), f'Columns in the CSV mapping should be: {",".join(CSV_HEADER)}'
list_cor = list(csv_reader)
if not folder.is_dir():
......
......@@ -45,6 +45,11 @@ def folder_bio():
return FIXTURES
@pytest.fixture()
def csv_file_error():
return FIXTURES / "test_mapping_file_error.csv"
@pytest.fixture()
def csv_file():
return FIXTURES / "test_mapping_file.csv"
Annotation,Prediction
demo_annot.bio,demo_predict.bio
toy_test_annot.bio,toy_test_predict.bio
\ No newline at end of file
Anno,Pred
demo_annot.bio,demo_predict.bio
toy_test_annot.bio,toy_test_predict.bio
\ No newline at end of file
......@@ -114,6 +114,13 @@ def test_run_empty_entry():
evaluate.run(Path("invalid.bio"), Path("invalid.bio"), 0.3, False)
def test_run_invalid_header(csv_file_error, folder_bio):
with pytest.raises(
Exception, match="Columns in the CSV mapping should be: Annotation,Prediction"
):
evaluate.run_multiple(csv_file_error, folder_bio, 0.3, False)
def test_run_multiple(csv_file, folder_bio):
with pytest.raises(
Exception, match="No file found for files demo_annot.bio, demo_predict.bio"
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment