Skip to content

Commit f40690b

Browse files
committed
update
1 parent 5df4487 commit f40690b

File tree

2 files changed

+22
-1
lines changed

2 files changed

+22
-1
lines changed

tests/processing/test_utilities.py

+11-1
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ def test_extract_rank_and_index_from_filename():
7272
assert index == rank_and_index[idx][1]
7373

7474

75-
def test_read_index_file_content(tmpdir):
75+
def test_read_index_file_content(tmpdir, monkeypatch):
7676
output_dir = tmpdir / "output_dir"
7777

7878
assert read_index_file_content(_resolve_dir(str(output_dir))) is None
@@ -86,6 +86,16 @@ def test_read_index_file_content(tmpdir):
8686

8787
assert read_index_file_content(_resolve_dir(str(output_dir))) == dummy_dict
8888

89+
def _fn(remote_path, local_path):
90+
with open(local_path, "w") as f:
91+
json.dump(dummy_dict, f)
92+
93+
fs_provider = MagicMock()
94+
fs_provider.download_file = _fn
95+
96+
monkeypatch.setattr(utilities_module, "_get_fs_provider", MagicMock(return_value=fs_provider))
97+
assert read_index_file_content(_resolve_dir("s3://bucket/path")) == dummy_dict
98+
8999

90100
def test_remove_uuid_from_filename():
91101
filepaths = [

tests/streaming/test_resolver.py

+11
Original file line numberDiff line numberDiff line change
@@ -359,6 +359,17 @@ def test_assert_dir_has_index_file(monkeypatch):
359359

360360
resolver._assert_dir_has_index_file(resolver.Dir(path="/teamspace/...", url="s3://"))
361361

362+
fs_provider.exists = mock.MagicMock(return_value=True)
363+
364+
fs_provider.is_empty = mock.MagicMock(return_value=False)
365+
fs_provider.delete_file_or_directory = mock.MagicMock()
366+
367+
resolver._assert_dir_has_index_file(resolver.Dir(path="/teamspace/...", url="s3://"), mode="overwrite")
368+
369+
resolver._assert_dir_has_index_file(resolver.Dir(path="/teamspace/...", url="s3://"), mode="append")
370+
371+
assert fs_provider.delete_file_or_directory.call_count == 1
372+
362373

363374
def test_resolve_dir_absolute(tmp_path, monkeypatch):
364375
"""Test that the directory gets resolved to an absolute path and symlinks are followed."""

0 commit comments

Comments
 (0)