18
18
19
19
from pulpcore .client .pulp_rpm import Copy
20
20
from pulpcore .client .pulp_rpm .exceptions import ApiException
21
+ import subprocess
21
22
22
23
24
+ def noop (uri ):
25
+ return uri
26
+
27
+
28
+ def get_prn (uri ):
29
+ """Utility to get prn without having to setup django.
30
+ TODO: This is a Copy-paste from pulpcore. Make it public there.
31
+ """
32
+ commands = f"from pulpcore.app.util import get_prn; print(get_prn(uri='{ uri } '));"
33
+ process = subprocess .run (["pulpcore-manager" , "shell" , "-c" , commands ], capture_output = True )
34
+
35
+ assert process .returncode == 0
36
+ prn = process .stdout .decode ().strip ()
37
+ return prn
38
+
39
+
40
+ @pytest .mark .parametrize ("get_id" , [noop , get_prn ], ids = ["without-prn" , "with-prn" ])
23
41
@pytest .mark .parallel
24
42
def test_modular_static_context_copy (
25
43
init_and_sync ,
@@ -28,13 +46,19 @@ def test_modular_static_context_copy(
28
46
rpm_modulemd_api ,
29
47
rpm_repository_factory ,
30
48
rpm_repository_api ,
49
+ get_id ,
31
50
):
32
51
"""Test copying a static_context-using repo to an empty destination."""
33
52
src , _ = init_and_sync (url = RPM_MODULES_STATIC_CONTEXT_FIXTURE_URL )
34
53
dest = rpm_repository_factory ()
35
54
36
55
data = Copy (
37
- config = [{"source_repo_version" : src .latest_version_href , "dest_repo" : dest .pulp_href }],
56
+ config = [
57
+ {
58
+ "source_repo_version" : get_id (src .latest_version_href ),
59
+ "dest_repo" : get_id (dest .pulp_href ),
60
+ }
61
+ ],
38
62
dependency_solving = False ,
39
63
)
40
64
monitor_task (rpm_copy_api .copy_content (data ).task )
@@ -44,7 +68,7 @@ def test_modular_static_context_copy(
44
68
assert get_content_summary (dest .to_dict ()) == RPM_MODULAR_STATIC_FIXTURE_SUMMARY
45
69
assert get_added_content_summary (dest .to_dict ()) == RPM_MODULAR_STATIC_FIXTURE_SUMMARY
46
70
47
- modules = rpm_modulemd_api .list (repository_version = dest .latest_version_href ).results
71
+ modules = rpm_modulemd_api .list (repository_version = get_id ( dest .latest_version_href ) ).results
48
72
module_static_contexts = [
49
73
(module .name , module .version ) for module in modules if module .static_context
50
74
]
@@ -141,6 +165,7 @@ def test_invalid_config(
141
165
)
142
166
rpm_copy_api .copy_content (data )
143
167
168
+ @pytest .mark .parametrize ("get_id" , [noop , get_prn ], ids = ["without-prn" , "with-prn" ])
144
169
def test_content (
145
170
self ,
146
171
monitor_task ,
@@ -149,20 +174,21 @@ def test_content(
149
174
rpm_repository_api ,
150
175
rpm_repository_factory ,
151
176
rpm_unsigned_repo_immediate ,
177
+ get_id ,
152
178
):
153
179
"""Test the content parameter."""
154
180
src = rpm_unsigned_repo_immediate
155
181
156
182
content = rpm_advisory_api .list (repository_version = src .latest_version_href ).results
157
- content_to_copy = (content [0 ].pulp_href , content [1 ].pulp_href )
183
+ content_to_copy = (get_id ( content [0 ].pulp_href ), get_id ( content [1 ].pulp_href ) )
158
184
159
185
dest = rpm_repository_factory ()
160
186
161
187
data = Copy (
162
188
config = [
163
189
{
164
- "source_repo_version" : src .latest_version_href ,
165
- "dest_repo" : dest .pulp_href ,
190
+ "source_repo_version" : get_id ( src .latest_version_href ) ,
191
+ "dest_repo" : get_id ( dest .pulp_href ) ,
166
192
"content" : content_to_copy ,
167
193
}
168
194
],
@@ -172,7 +198,7 @@ def test_content(
172
198
173
199
dest = rpm_repository_api .read (dest .pulp_href )
174
200
dc = rpm_advisory_api .list (repository_version = dest .latest_version_href )
175
- dest_content = [c .pulp_href for c in dc .results ]
201
+ dest_content = [get_id ( c .pulp_href ) for c in dc .results ]
176
202
177
203
assert sorted (content_to_copy ) == sorted (dest_content )
178
204
0 commit comments