TestPathManager test_instantiate_without_file fails with existing `path_config.env
Describe the bug The test fails in this line
self.assertEqual(path_manager.get_mcx_binary_path(), "test_mcx_path")
when the MCX_BINARY_PATH is set in path_config.env in the home directory.
Specify a priority (low, medium, high) medium
To Reproduce Steps to reproduce the behavior:
- Setup python 3
- Setup virtual environment
- Install SIMPA from develop 1226692
- Create
path_config.envfile in home directory with MCX_BINARY_PATH set to a path - Run simpa_tests/automatic_tests/test_path_manager.py
- See failing test
Current Behavior
Test fails with:
AssertionError: '/home/tom/dev/mcx/bin/mcx' != 'test_mcx_path'
Expected behavior Test passes
Environment (please complete the following information):
- OS: Ubuntu 22.04
- SIMPA version: 1226692
- IDE VSCode
Additional context Add any other context about the problem here, e.g. possible solution(s).
Maybe @leoyala knows more? Is there a solution with @patch.dict decorators?
Theoretically, the decorator in that test should set the environment variable for the mcx path to "test_mcx_path". This should be the path that MCX uses for the path manager. I do see that there might be some conflicts if botht eh path in the home directory is set and when not. @TomTomRixRix are you working on this?
Ok, I see. With the new option to set the SIMPA_SAVE_PATH in environment variables it is unclear which option is prioritized in the order: https://github.com/IMSY-DKFZ/simpa/tree/develop?tab=readme-ov-file#path-management
I would suggest the following order:
- The optional path you give the PathManager
- The environment variables
- Your home directory
- The current working directory
- The SIMPA home directory path
That order of priority seems good to me
Fixed by #347