88import pytest
99
1010import oras .client
11+ import oras .provider
1112
1213here = os .path .abspath (os .path .dirname (__file__ ))
1314
@@ -67,6 +68,40 @@ def test_basic_push_pull(tmp_path, registry, credentials, target):
6768 assert res .status_code == 201
6869
6970
71+
72+ @pytest .mark .with_auth (False )
73+ def test_push_pull_attached_artifacts (tmp_path , registry , credentials , target , derived_target ):
74+ """
75+ Basic tests for oras (without authentication)
76+ """
77+ client = oras .client .OrasClient (hostname = registry , insecure = True )
78+
79+ artifact = os .path .join (here , "artifact.txt" )
80+ assert os .path .exists (artifact )
81+
82+ res = client .push (files = [artifact ], target = target )
83+ assert res .status_code in [200 , 201 ]
84+
85+ derived_artifact = os .path .join (here , "derived-artifact.txt" )
86+ assert os .path .exists (derived_artifact )
87+
88+ manifest = client .remote .get_manifest (target )
89+ subject = oras .provider .Subject .from_manifest (manifest )
90+ res = client .push (files = [derived_artifact ], target = derived_target , subject = subject )
91+ assert res .status_code in [200 , 201 ]
92+
93+ # Test pulling elsewhere
94+ files = sorted (client .pull (target = derived_target , outdir = tmp_path , include_subject = True ))
95+ assert len (files ) == 2
96+ assert os .path .basename (files [0 ]) == "artifact.txt"
97+ assert os .path .basename (files [1 ]) == "derived-artifact.txt"
98+ assert str (tmp_path ) in files [0 ]
99+ assert str (tmp_path ) in files [1 ]
100+ assert os .path .exists (files [0 ])
101+ assert os .path .exists (files [1 ])
102+
103+
104+
70105@pytest .mark .with_auth (False )
71106def test_get_delete_tags (tmp_path , registry , credentials , target ):
72107 """
@@ -87,7 +122,7 @@ def test_get_delete_tags(tmp_path, registry, credentials, target):
87122 assert not client .delete_tags (target , "v1-boop-boop" )
88123 assert "v1" in client .delete_tags (target , "v1" )
89124 tags = client .get_tags (target )
90- assert not tags
125+ assert "v1" not in tags
91126
92127
93128def test_get_many_tags ():
0 commit comments