Skip to content

Commit f10c89d

Browse files
Test progress on parent operation (#307)
1 parent cbc25bc commit f10c89d

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed

tests/copy_test.py

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,3 +103,38 @@ def test_copy_empty_file(storage_path, client):
103103
assert op.id is not None
104104
op = api.wait_for(op.id)
105105
assert op[0].state == OperationState.Succeeded, op[0].messages
106+
107+
108+
def test_multi_copy_parent_progress(storage_path, client):
109+
"""Test progress of parent operation when copying multiple files."""
110+
111+
api = DataTransferApi(client)
112+
api.status(wait=True)
113+
114+
operations = []
115+
116+
for _ in range(3):
117+
with tempfile.NamedTemporaryFile(mode="w", delete=False) as temp_file:
118+
temp_file.write("Mock file")
119+
temp_file_name = os.path.basename(temp_file.name)
120+
121+
src = StoragePath(path=temp_file.name, remote="local")
122+
dst = StoragePath(path=f"{storage_path}/{temp_file_name}")
123+
operations.append(SrcDst(src=src, dst=dst))
124+
125+
op = api.copy(operations)
126+
127+
assert op.id is not None
128+
129+
# test progress handler
130+
progress_history = []
131+
132+
def handler(ops):
133+
for o in ops:
134+
if o.id == op.id:
135+
progress_history.append(o.progress)
136+
137+
op = api.wait_for(op.id, interval=0.05, handler=handler)
138+
assert op[0].state == OperationState.Succeeded, op[0].messages
139+
140+
assert None not in progress_history, f"{progress_history=}"

0 commit comments

Comments
 (0)