From efa67adb2e6d3c21146516e2079c1a67b534b476 Mon Sep 17 00:00:00 2001 From: JoeZiminski Date: Sat, 21 Oct 2023 13:21:12 +0100 Subject: [PATCH] Fix tests. --- .../file_conflicts_pathtable.py | 14 +++++++------- .../test_filesystem_transfer.py | 4 ++-- tests/tests_integration/test_logging.py | 6 +++--- tests/tests_integration/test_make_folders.py | 17 ++++++++++------- .../tests_integration/test_ssh_file_transfer.py | 5 ----- 5 files changed, 22 insertions(+), 24 deletions(-) diff --git a/tests/tests_integration/file_conflicts_pathtable.py b/tests/tests_integration/file_conflicts_pathtable.py index 224a0c11a..56b63dd8c 100644 --- a/tests/tests_integration/file_conflicts_pathtable.py +++ b/tests/tests_integration/file_conflicts_pathtable.py @@ -16,19 +16,19 @@ def get_pathtable(base_folder): [base_folder, Path("rawdata") / "sub-001" / "ses-003_date-20231901" / "behav" / "behav.csv", False, False, False, "sub-001", "ses-003_date-20231901", "behav"], [base_folder, Path("rawdata") / "sub-001" / "ses-003_date-20231901" / "ephys" / "ephys.bin", False, False, False, "sub-001", "ses-003_date-20231901", "ephys"], [base_folder, Path("rawdata") / "sub-001" / "ses-003_date-20231901" / "non_data" / "non_data.mp4", False, False, True, "sub-001", "ses-003_date-20231901", None], - [base_folder, Path("rawdata") / "sub-001" / "ses-003_date-20231901" / "nondatatype_level_file.csv", False, False, True, "sub-001", "ses-003_date-20231901", None], + [base_folder, Path("rawdata") / "sub-001" / "ses-003_date-20231901" / "nondatatype_level_file.csv", False, False, True, "sub-001", "ses-003_date-20231901", None], [base_folder, Path("rawdata") / "sub-001" / "random-ses_level_file.mp4", False, True, False, "sub-001", None, None], - [base_folder, Path("rawdata") / "sub-001" / "anat" / "sub-001_anat.file", False, False, False, "sub-001", None, "anat"], + [base_folder, Path("rawdata") / "sub-001" / "ses-004" / "anat" / "sub-001_anat.file", False, False, False, "sub-001", "ses-004", "anat"], [base_folder, Path("rawdata") / "sub-002_random-value" / "sub-002_random-value.file", False, True, False, "sub-002_random-value", None, None], - [base_folder, Path("rawdata") / "sub-002_random-value" / "ses-001" / "non_datatype_level_folder" / "file.csv", False, False, True, "sub-002_random-value", "ses-001", None], + [base_folder, Path("rawdata") / "sub-002_random-value" / "ses-001" / "non_datatype_level_folder" / "file.csv", False, False, True, "sub-002_random-value", "ses-001", None], [base_folder, Path("rawdata") / "sub-003_date-20231901" / "ses-001" / "funcimg" / ".myfile.xlsx", False, False, False, "sub-003_date-20231901", "ses-001", "funcimg"], - [base_folder, Path("rawdata") / "sub-003_date-20231901" / "ses-003_date-20231901" / "nondatatype_level_file.csv", False, False, True, "sub-003_date-20231901", "ses-003_date-20231901", None], + [base_folder, Path("rawdata") / "sub-003_date-20231901" / "ses-003_date-20231901" / "nondatatype_level_file.csv", False, False, True, "sub-003_date-20231901", "ses-003_date-20231901", None], [base_folder, Path("rawdata") / "sub-003_date-20231901" / "ses-003_date-20231901" / "funcimg" / "funcimg.nii", False, False, False, "sub-003_date-20231901", "ses-003_date-20231901", "funcimg"], - [base_folder, Path("rawdata") / "sub-003_date-20231901" / "seslevel_non-prefix_folder" / "nonlevel.mat", False, True, False, "sub-003_date-20231901", "seslevel_non-prefix_folder", None], + [base_folder, Path("rawdata") / "sub-003_date-20231901" / "seslevel_non-prefix_folder" / "nonlevel.mat", False, True, False, "sub-003_date-20231901", "seslevel_non-prefix_folder", None], [base_folder, Path("rawdata") / "sub-003_date-20231901" / "sub-ses-level_file.txt", False, True, False, "sub-003_date-20231901", None, None], - [base_folder, Path("rawdata") / "sub-003_date-20231901" / "anat" / ".anat.file", False, False, False, "sub-003_date-20231901", None, "anat"], + [base_folder, Path("rawdata") / "sub-003_date-20231901" / "ses-004" / "anat" / ".anat.file", False, False, False, "sub-003_date-20231901", "ses-004", "anat"], [base_folder, Path("rawdata") / "project_level_file.txt", True, False, False, None, None, None], - [base_folder, Path("rawdata") / "sublevel_non_sub-prefix_folder" / "ses_non_folder.file", True, False, False, None, None, None], + [base_folder, Path("rawdata") / "sublevel_non_sub-prefix_folder" / "ses_non_folder.file", True, False, False, None, None, None], ] diff --git a/tests/tests_integration/test_filesystem_transfer.py b/tests/tests_integration/test_filesystem_transfer.py index 221c16c6a..14ec77daf 100644 --- a/tests/tests_integration/test_filesystem_transfer.py +++ b/tests/tests_integration/test_filesystem_transfer.py @@ -429,10 +429,10 @@ def test_rclone_overwrite_modified_file( the version in source is newer than target. """ path_to_test_file = ( - Path("rawdata") / "sub-001" / "anat" / "test_file.txt" + Path("rawdata") / "sub-001" / "ses-001" / "anat" / "test_file.txt" ) - project.make_folders("sub-001", datatype="anat") + project.make_folders("sub-001", "ses-001", datatype="anat") local_test_file_path = project.cfg["local_path"] / path_to_test_file central_test_file_path = ( diff --git a/tests/tests_integration/test_logging.py b/tests/tests_integration/test_logging.py index d3196c02f..4c4f3583d 100644 --- a/tests/tests_integration/test_logging.py +++ b/tests/tests_integration/test_logging.py @@ -286,9 +286,9 @@ def test_logs_upload_and_download( assert "Using config file from" in log assert "Local file system at" in log - - assert """ "--include" "sub-11/anat/**" """ in log - assert """/central/test_project/rawdata""" in log + assert "--include" in log + assert "sub-11/ses-123/anat/**" in log + assert "/central/test_project/rawdata" in log assert "Waiting for checks to finish" in log @pytest.mark.parametrize("upload_or_download", ["upload", "download"]) diff --git a/tests/tests_integration/test_make_folders.py b/tests/tests_integration/test_make_folders.py index 85276a5a0..dde4a6e45 100644 --- a/tests/tests_integration/test_make_folders.py +++ b/tests/tests_integration/test_make_folders.py @@ -133,7 +133,9 @@ def test_explicitly_session_list(self, project): test_utils.check_and_cd_folder( join(base_folder, sub, ses, "funcimg") ) - test_utils.check_and_cd_folder(join(base_folder, sub, "anat")) + test_utils.check_and_cd_folder( + join(base_folder, sub, ses, "anat") + ) @pytest.mark.parametrize("behav", [True, False]) @pytest.mark.parametrize("ephys", [True, False]) @@ -210,7 +212,9 @@ def test_custom_folder_names(self, project): join(base_folder, sub, ses, "change_funcimg") ) - test_utils.check_and_cd_folder(join(base_folder, sub, "change_anat")) + test_utils.check_and_cd_folder( + join(base_folder, sub, ses, "change_anat") + ) @pytest.mark.parametrize( "files_to_test", @@ -238,13 +242,10 @@ def test_datatypes_subsection(self, project, files_to_test): base_folder = test_utils.get_top_level_folder_path(project) # Check at the subject level - sub_file_names = test_utils.glob_basenames( + test_utils.glob_basenames( join(base_folder, sub, "*"), exclude=ses, ) - if "anat" in files_to_test: - assert "anat" in sub_file_names - files_to_test.remove("anat") # Check at the session level ses_file_names = test_utils.glob_basenames( @@ -253,7 +254,9 @@ def test_datatypes_subsection(self, project, files_to_test): ) if files_to_test == ["all"]: - assert ses_file_names == sorted(["ephys", "behav", "funcimg"]) + assert ses_file_names == sorted( + ["ephys", "behav", "funcimg", "anat"] + ) else: assert ses_file_names == sorted(files_to_test) diff --git a/tests/tests_integration/test_ssh_file_transfer.py b/tests/tests_integration/test_ssh_file_transfer.py index f249d827c..989dbfbf9 100644 --- a/tests/tests_integration/test_ssh_file_transfer.py +++ b/tests/tests_integration/test_ssh_file_transfer.py @@ -296,11 +296,6 @@ def make_pathtable_search_filter(self, sub_names, ses_names, datatype): if sub == "all_non_sub": extra_arguments += ["is_non_sub == True"] else: - if "anat" in datatype: - sub_ses_dtype_arguments += [ - f"(parent_sub == '{sub}' & (parent_datatype == 'anat' | parent_datatype == 'anat'))" - ] - for ses in ses_names: if ses == "all_non_ses": extra_arguments += [