Skip to content

Commit

Permalink
Test refactoring: use tmp path fixture to mock remote and local for t…
Browse files Browse the repository at this point in the history
…ransport plugins (#6627)

In `tests/transport/test_all_plugins.py`, the tests were first wrote couple years ago before there were tmp_path fixture from pytest. The tmp folders were created and shared between multiple tests. When running tests in parallel, they will failed because of override. 
This commit refactoring all the tests in this file by using `tmp_path_factory` to create `tmp_path_remote` and `tmp_path_local` respectively to mock the transport behavior from different folder in different location.

---------
Co-authored-by: Ali Khosravi  <[email protected]>
  • Loading branch information
unkcpz authored Nov 29, 2024
1 parent 9baf3ca commit 197c666
Show file tree
Hide file tree
Showing 2 changed files with 436 additions and 583 deletions.
7 changes: 5 additions & 2 deletions src/aiida/transports/plugins/local.py
Original file line number Diff line number Diff line change
Expand Up @@ -453,15 +453,18 @@ def getfile(self, remotepath, localpath, *args, **kwargs):
"""Copies a file recursively from 'remote' remotepath to
'local' localpath.
:param remotepath: path to local file
:param localpath: absolute path to remote file
:param remotepath: absolute path to remote file
:param localpath: path to local file
:param overwrite: if True overwrites localpath.
Default = False
:raise OSError if 'remote' remotepath is not valid or not found
:raise ValueError: if 'local' localpath is not valid
:raise OSError: if unintentionally overwriting
"""
if not os.path.isabs(localpath):
raise ValueError('localpath must be an absolute path')

overwrite = kwargs.get('overwrite', args[0] if args else True)
if not localpath:
raise ValueError('Input localpath to get function must be a non empty string')
Expand Down
Loading

0 comments on commit 197c666

Please sign in to comment.