File tree Expand file tree Collapse file tree 2 files changed +13
-4
lines changed
src/power_grid_model_io/utils Expand file tree Collapse file tree 2 files changed +13
-4
lines changed Original file line number Diff line number Diff line change @@ -215,7 +215,7 @@ def get_download_path(
215215 """
216216
217217 # If no specific download path was given, we need to generate a unique key (based on the given unique key)
218- if dir_path is None or file_name is None :
218+ if file_name is None or unique_key is not None :
219219 if unique_key is None :
220220 raise ValueError ("Supply a unique key in order to auto generate a download path." )
221221
@@ -228,8 +228,7 @@ def get_download_path(
228228 if file_name is None :
229229 file_name = Path (f"{ unique_key } .download" )
230230 # Otherwise, use the unique key as a sub directory
231- else :
232- assert dir_path is None # sanity check
231+ elif dir_path is None :
233232 dir_path = Path (tempfile .gettempdir ()) / unique_key
234233
235234 # If no dir_path is given, use the system's designated folder for temporary files.
Original file line number Diff line number Diff line change 2626# The / and + will be replaced with a _ and - character and the trailing = character(s) will be removed.
2727FOO_KEY = "LCa0a2j_xo_5m0U8HTBBNBNCLXBkg7-g-YpeiGJm564"
2828
29+ TEMP_DIR = Path (tempfile .gettempdir ()).resolve ()
30+
2931
3032@pytest .fixture ()
3133def temp_dir ():
@@ -374,12 +376,20 @@ def test_get_download_path__ignore_unique_key(temp_dir: Path):
374376 assert path == temp_dir / "file_name.zip"
375377
376378
379+ def test_get_download_path__temp_dir ():
380+ # Act
381+ path = get_download_path (file_name = "file_name.zip" )
382+
383+ # Assert
384+ assert path == TEMP_DIR / "file_name.zip"
385+
386+
377387def test_get_download_path__auto_dir ():
378388 # Act
379389 path = get_download_path (file_name = "file_name.zip" , unique_key = "foo" )
380390
381391 # Assert
382- assert path == Path ( tempfile . gettempdir ()). resolve () / FOO_KEY / "file_name.zip"
392+ assert path == TEMP_DIR / FOO_KEY / "file_name.zip"
383393
384394
385395def test_get_download_path__auto_file_name (temp_dir : Path ):
You can’t perform that action at this time.
0 commit comments