Skip to content

Commit 32982ea

Browse files
committed
Fix test_directory_push_pull_skip_unpack
Rewrite test to test the functionality to only unpack if the annotation is set. Signed-off-by: Stefan Lietzau <[email protected]>
1 parent f5b230c commit 32982ea

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

oras/tests/test_oras.py

+10-4
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,14 @@
22
__copyright__ = "Copyright The ORAS Authors."
33
__license__ = "Apache-2.0"
44

5+
import json
56
import os
67
import shutil
78

89
import pytest
910

1011
import oras.client
12+
import oras.oci
1113

1214
here = os.path.abspath(os.path.dirname(__file__))
1315

@@ -168,14 +170,18 @@ def test_directory_push_pull_skip_unpack(tmp_path, registry, credentials, target
168170
"""
169171
client = oras.client.OrasClient(hostname=registry, insecure=True)
170172

171-
# Test upload of a directory
173+
# Test upload of a directory with an annotation file setting oras.defaults.annotation_unpack to False
172174
upload_dir = os.path.join(here, "upload_data")
173-
res = client.push(files=[upload_dir], target=target_dir)
175+
annotation_file = os.path.join(here, "annotations.json")
176+
with open(annotation_file, "w") as f:
177+
json.dump({str(upload_dir):{"oras.defaults.annotation_unpack": "False"}}, f)
178+
179+
res = client.push(files=[upload_dir], target=target_dir, annotation_file=annotation_file)
174180
assert res.status_code == 201
175-
files = client.pull(target=target_dir, outdir=tmp_path, skip_unpack=True)
181+
files = client.pull(target=target_dir, outdir=tmp_path)
176182

177183
assert len(files) == 1
178-
assert os.path.basename(files[0]) == "upload_data.tar.gz"
184+
assert os.path.basename(files[0]) == os.path.basename(upload_dir)
179185
assert str(tmp_path) in files[0]
180186
assert os.path.exists(files[0])
181187

0 commit comments

Comments
 (0)