Skip to content
Snippets Groups Projects
Commit 214c4a1c authored by Christopher Randolph Rhodes's avatar Christopher Randolph Rhodes
Browse files

Added setter to change one a session's data paths

parent 9e996c00
No related branches found
No related tags found
No related merge requests found
......@@ -36,6 +36,13 @@ class Session(object):
def get_paths(self):
return self.paths
def set_data_directory(self, key: str, path: Path):
if not key in self.paths.keys():
raise InvalidPathError(f'No such path {key}')
if not Path(path).exists():
raise InvalidPathError(f'Could not find {path}')
self.paths[key] = path
@staticmethod
def make_paths(root: str = None) -> dict:
"""
......@@ -143,4 +150,7 @@ class CouldNotInstantiateModelError(Error):
pass
class CouldNotCreateDirectory(Error):
pass
class InvalidPathError(Error):
pass
\ No newline at end of file
......@@ -28,6 +28,13 @@ class TestGetSessionObject(unittest.TestCase):
rmtree(newroot)
self.assertFalse(newroot.exists(), 'Could not clean up temporary test subdirectory')
def test_change_session_subdirectory(self):
sesh = Session()
old_paths = sesh.get_paths()
print(old_paths)
sesh.set_data_directory('outbound_images', old_paths['inbound_images'])
self.assertEqual(sesh.paths['outbound_images'], sesh.paths['inbound_images'])
def test_restart_session(self):
sesh = Session()
......
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