Skip to content

Commit

Permalink
Fix test_directory_push_pull_skip_unpack
Browse files Browse the repository at this point in the history
Rewrite test to test the functionality to only unpack if the annotation is set.
  • Loading branch information
stefansli committed Dec 10, 2024
1 parent 0b0c67d commit f0fa560
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions oras/tests/test_oras.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,14 @@
__copyright__ = "Copyright The ORAS Authors."
__license__ = "Apache-2.0"

import json
import os
import shutil

import pytest

import oras.client
import oras.oci

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

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

# Test upload of a directory
# Test upload of a directory with an annotation file setting oras.defaults.annotation_unpack to False
upload_dir = os.path.join(here, "upload_data")
res = client.push(files=[upload_dir], target=target_dir)
annotation_file = os.path.join(here, "annotations.json")
with open(annotation_file, "w") as f:
json.dump({str(upload_dir):{"oras.defaults.annotation_unpack": "False"}}, f)

res = client.push(files=[upload_dir], target=target_dir, annotation_file=annotation_file)
assert res.status_code == 201
files = client.pull(target=target_dir, outdir=tmp_path, skip_unpack=True)
files = client.pull(target=target_dir, outdir=tmp_path)

assert len(files) == 1
assert os.path.basename(files[0]) == "upload_data.tar.gz"
assert os.path.basename(files[0]) == os.path.basename(upload_dir)
assert str(tmp_path) in files[0]
assert os.path.exists(files[0])

Expand Down

0 comments on commit f0fa560

Please sign in to comment.