|  | 
| 2 | 2 | __copyright__ = "Copyright The ORAS Authors." | 
| 3 | 3 | __license__ = "Apache-2.0" | 
| 4 | 4 | 
 | 
|  | 5 | +import json | 
| 5 | 6 | import os | 
| 6 | 7 | import shutil | 
| 7 | 8 | 
 | 
| 8 | 9 | import pytest | 
| 9 | 10 | 
 | 
| 10 | 11 | import oras.client | 
|  | 12 | +import oras.oci | 
| 11 | 13 | 
 | 
| 12 | 14 | here = os.path.abspath(os.path.dirname(__file__)) | 
| 13 | 15 | 
 | 
| @@ -168,14 +170,18 @@ def test_directory_push_pull_skip_unpack(tmp_path, registry, credentials, target | 
| 168 | 170 |     """ | 
| 169 | 171 |     client = oras.client.OrasClient(hostname=registry, insecure=True) | 
| 170 | 172 | 
 | 
| 171 |  | -    # Test upload of a directory | 
|  | 173 | +    # Test upload of a directory with an annotation file setting oras.defaults.annotation_unpack to False | 
| 172 | 174 |     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) | 
| 174 | 180 |     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) | 
| 176 | 182 | 
 | 
| 177 | 183 |     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) | 
| 179 | 185 |     assert str(tmp_path) in files[0] | 
| 180 | 186 |     assert os.path.exists(files[0]) | 
| 181 | 187 | 
 | 
|  | 
0 commit comments