diff --git a/.github/workflows/pytest.yml b/.github/workflows/pytest.yml index abd123d..78caead 100644 --- a/.github/workflows/pytest.yml +++ b/.github/workflows/pytest.yml @@ -26,4 +26,4 @@ jobs: run: uv pip install --editable ./ - name: Run tests with uv - run: uv run pytest \ No newline at end of file + run: uv run pytest tests \ No newline at end of file diff --git a/.gitignore b/.gitignore index cfa822b..bdc95a7 100644 --- a/.gitignore +++ b/.gitignore @@ -9,6 +9,7 @@ empty_log_process_temp.py tests/**/bids/ tests/test_main_functionality/data/projects/test-project/sub-100 +tests/pytest-autobids_config.yaml tests/data # Byte-compiled / optimized / DLL files __pycache__/ diff --git a/lslautobids/datalad_create.py b/lslautobids/datalad_create.py index 830c8d0..6f066b8 100644 --- a/lslautobids/datalad_create.py +++ b/lslautobids/datalad_create.py @@ -7,7 +7,7 @@ def create_and_add_files_to_datalad_dataset(dataset_path,logger): #if flag==0: try: - dl.Dataset(dataset_path) + dl.Dataset(dataset_path).status() except: message ="LSL Auto BIDS: new datalad dataset created" # Create a new dataset @@ -30,5 +30,6 @@ def create_and_add_files_to_datalad_dataset(dataset_path,logger): # commit current files logger.info('Committing current changes........') + os.chdir(dataset_path) # bug in datalad that requires to be in the same folder to save the datalad thingy dl.save(path = dataset_path, message=message) diff --git a/tests/conftest.py b/tests/conftest.py index 3523e2e..8639661 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -35,8 +35,8 @@ def setup_project(monkeypatch): from lslautobids.gen_project_config import main as gen_project_config_main - # Create dummy user config for the test - config_file_test = ("tests/pytest-autobids_config.yaml") + # Create dummy user config for the test using absolute path + config_file_test = os.path.join(PROJECT_ROOT, "pytest-autobids_config.yaml") #os.makedirs(os.path.dirname(config_file_test), exist_ok=True) config_data = { diff --git a/tests/pytest-autobids_config.yaml b/tests/pytest-autobids_config.yaml deleted file mode 100644 index c18e2aa..0000000 --- a/tests/pytest-autobids_config.yaml +++ /dev/null @@ -1,3 +0,0 @@ -BIDS_ROOT: /Users/xuyg/GitHub/LSLAutoBIDS/tests/data/bids -PROJECT_OTHER_ROOT: /Users/xuyg/GitHub/LSLAutoBIDS/tests/data/project_other -PROJECT_ROOT: /Users/xuyg/GitHub/LSLAutoBIDS/tests/data/projects diff --git a/tests/test_main_functionality/test_main_functionality.py b/tests/test_main_functionality/test_main_functionality.py index 095ef0a..614fb8d 100644 --- a/tests/test_main_functionality/test_main_functionality.py +++ b/tests/test_main_functionality/test_main_functionality.py @@ -64,8 +64,10 @@ def test_process_main_functionality(setup_project, monkeypatch): fixture_path = os.path.join(paths["bids_root"],project_name,"sub-100","ses-001","eeg","sub-100_ses-001_task-freeviewing_run-2_eeg.set") assert os.path.exists(fixture_path) - # cleanup + # cleanup shutil.rmtree(os.path.join(paths["project_root"], project_name,"sub-100")) + + # # does not work for some reason with git-annex, needs sudo #shutil.rmtree(paths["bids_root"]) diff --git a/tests/test_old_suffix/test_old_suffix.py b/tests/test_old_suffix/test_old_suffix.py index 8b35366..291fc81 100644 --- a/tests/test_old_suffix/test_old_suffix.py +++ b/tests/test_old_suffix/test_old_suffix.py @@ -33,6 +33,7 @@ def test_process_new_files_with_old_suffix(setup_project, monkeypatch): logger = get_logger(project_name) logger.debug(f" Starting test_process_new_files_with_old_suffix in {project_name} ") + # Reset sys.argv to something that lslautobids.main.main() expects sys.argv = [ "lslautobids.main", diff --git a/tests/test_otherfiles-renaming/test_otherfiles-renaming.py b/tests/test_otherfiles-renaming/test_otherfiles-renaming.py index 01e8865..974eac7 100644 --- a/tests/test_otherfiles-renaming/test_otherfiles-renaming.py +++ b/tests/test_otherfiles-renaming/test_otherfiles-renaming.py @@ -44,7 +44,7 @@ def test_process_otherfiles_renaming(setup_project, monkeypatch): import lslautobids.main lslautobids.main.main() - # cleanup - shutil.rmtree(paths["bids_root"]) + # cleanup # does not work for some reason with git-annex, needs sudo + #shutil.rmtree(paths["bids_root"])