Skip to content

Commit 8267bfd

Browse files
author
Bruno Grande
committed
Update tests for new File staging behavior
1 parent 689b2a2 commit 8267bfd

File tree

2 files changed

+13
-15
lines changed

2 files changed

+13
-15
lines changed

src/dcqc/file.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,7 @@ def stage(self, destination: Optional[str] = None, overwrite: bool = False) -> P
220220
with destination_path.open("wb") as dest_file:
221221
self.fs.download(self.fs_path, dest_file)
222222

223+
self.local_path = destination_path.as_posix()
223224
return destination_path
224225

225226
def to_dict(self) -> SerializedObject:

tests/test_file.py

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -33,18 +33,18 @@ def test_that_a_local_file_is_not_moved_when_requesting_a_local_path(test_files)
3333

3434

3535
@pytest.mark.integration
36-
def test_for_an_error_when_requesting_a_local_path_for_a_remote_file(test_files):
36+
def test_for_an_error_when_getting_local_path_for_an_unstaged_remote_file(test_files):
3737
file = test_files["synapse"]
38-
with pytest.raises(FileNotFoundError):
38+
with pytest.raises(ValueError):
3939
file.get_local_path()
4040

4141

4242
@pytest.mark.integration
4343
def test_that_a_local_file_is_not_moved_when_staged_without_a_destination(test_files):
4444
test_file = test_files["good"]
45-
url_before = test_file.url
46-
url_after = test_file.stage()
47-
assert url_before == url_after
45+
path_before = test_file.get_local_path()
46+
path_after = test_file.stage()
47+
assert path_before == path_after
4848

4949

5050
@pytest.mark.integration
@@ -59,23 +59,20 @@ def test_that_a_local_file_is_symlinked_when_staged_with_a_destination(test_file
5959

6060

6161
@pytest.mark.integration
62-
def test_for_an_error_when_a_remote_file_is_staged_without_a_destination(test_files):
62+
def test_that_a_local_temporary_path_is_created_when_staging_a_remote_file(test_files):
6363
file = test_files["synapse"]
64-
with pytest.raises(ValueError):
65-
file.stage()
64+
file.stage()
65+
assert file.get_local_path() is not None
6666

6767

6868
@pytest.mark.integration
69-
def test_that_a_remote_file_is_moved_when_staged_with_a_destination(test_files):
69+
def test_that_a_remote_file_is_created_when_staged_with_a_destination(test_files):
7070
test_file = test_files["synapse"]
7171
with TemporaryDirectory() as tmp_dir:
72-
original_url = test_file.url
7372
test_file.stage(tmp_dir)
74-
after_url = test_file.url
75-
after_path = Path(test_file.get_local_path())
76-
assert original_url != after_url
77-
assert after_path.exists()
78-
assert not after_path.is_symlink()
73+
local_path = test_file.get_local_path()
74+
assert local_path.exists()
75+
assert not local_path.is_symlink()
7976

8077

8178
def test_that_a_file_can_be_saved_and_restored_without_changing(test_files):

0 commit comments

Comments
 (0)