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(
215
215
"""
216
216
217
217
# 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 :
219
219
if unique_key is None :
220
220
raise ValueError ("Supply a unique key in order to auto generate a download path." )
221
221
@@ -228,8 +228,7 @@ def get_download_path(
228
228
if file_name is None :
229
229
file_name = Path (f"{ unique_key } .download" )
230
230
# 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 :
233
232
dir_path = Path (tempfile .gettempdir ()) / unique_key
234
233
235
234
# 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 26
26
# The / and + will be replaced with a _ and - character and the trailing = character(s) will be removed.
27
27
FOO_KEY = "LCa0a2j_xo_5m0U8HTBBNBNCLXBkg7-g-YpeiGJm564"
28
28
29
+ TEMP_DIR = Path (tempfile .gettempdir ()).resolve ()
30
+
29
31
30
32
@pytest .fixture ()
31
33
def temp_dir ():
@@ -374,12 +376,20 @@ def test_get_download_path__ignore_unique_key(temp_dir: Path):
374
376
assert path == temp_dir / "file_name.zip"
375
377
376
378
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
+
377
387
def test_get_download_path__auto_dir ():
378
388
# Act
379
389
path = get_download_path (file_name = "file_name.zip" , unique_key = "foo" )
380
390
381
391
# Assert
382
- assert path == Path ( tempfile . gettempdir ()). resolve () / FOO_KEY / "file_name.zip"
392
+ assert path == TEMP_DIR / FOO_KEY / "file_name.zip"
383
393
384
394
385
395
def test_get_download_path__auto_file_name (temp_dir : Path ):
You can’t perform that action at this time.
0 commit comments