8
8
import pytest
9
9
10
10
import oras .client
11
+ import oras .provider
11
12
12
13
here = os .path .abspath (os .path .dirname (__file__ ))
13
14
@@ -67,6 +68,40 @@ def test_basic_push_pull(tmp_path, registry, credentials, target):
67
68
assert res .status_code == 201
68
69
69
70
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
+
70
105
@pytest .mark .with_auth (False )
71
106
def test_get_delete_tags (tmp_path , registry , credentials , target ):
72
107
"""
@@ -87,7 +122,7 @@ def test_get_delete_tags(tmp_path, registry, credentials, target):
87
122
assert not client .delete_tags (target , "v1-boop-boop" )
88
123
assert "v1" in client .delete_tags (target , "v1" )
89
124
tags = client .get_tags (target )
90
- assert not tags
125
+ assert "v1" not in tags
91
126
92
127
93
128
def test_get_many_tags ():
0 commit comments