33import json
44
55from pulpcore .app import settings
6- from pulpcore .client .pulp_file import ApiException
7- from pulpcore .client .pulpcore import ApiException as CoreApiException
8- from pulpcore .client .pulpcore import Repair
96from pulpcore .tests .functional .utils import generate_iso , download_file
107
118
@@ -45,7 +42,7 @@ def test_object_creation(
4542
4643 # Try to create an object w/ cross domain relations
4744 default_remote = file_remote_factory (manifest_path = basic_manifest_path , policy = "immediate" )
48- with pytest .raises (ApiException ) as e :
45+ with pytest .raises (file_bindings . ApiException ) as e :
4946 repo_body = {"name" : str (uuid .uuid4 ()), "remote" : default_remote .pulp_href }
5047 file_bindings .RepositoriesFileApi .create (repo_body , pulp_domain = domain .name )
5148 assert e .value .status == 400
@@ -54,7 +51,7 @@ def test_object_creation(
5451 "non_field_errors" : [f"Objects must all be a part of the { domain_name } domain." ]
5552 }
5653
57- with pytest .raises (ApiException ) as e :
54+ with pytest .raises (file_bindings . ApiException ) as e :
5855 sync_body = {"remote" : default_remote .pulp_href }
5956 file_bindings .RepositoriesFileApi .sync (repo .pulp_href , sync_body )
6057 assert e .value .status == 400
@@ -115,15 +112,15 @@ def test_artifact_upload(
115112 assert second_artifact .sha256 == file ["digest" ]
116113
117114 # Test that duplicate artifact can not be uploaded in same domain
118- with pytest .raises (CoreApiException ) as e :
119- pulpcore_bindings .ArtifactsApi .create (filename , pulp_domain = domain .name )
115+ with pytest .raises (pulpcore_bindings . ApiException ) as e :
116+ pulpcore_bindings .ArtifactsApi .create (str ( filename ) , pulp_domain = domain .name )
120117 assert e .value .status == 400
121118 assert json .loads (e .value .body ) == {
122119 "non_field_errors" : [f"Artifact with sha256 checksum of '{ file ['digest' ]} ' already exists." ]
123120 }
124121
125122 # Show that duplicate artifacts can be uploaded into different domains
126- dup_artifact = pulpcore_bindings .ArtifactsApi .create (filename , pulp_domain = "default" )
123+ dup_artifact = pulpcore_bindings .ArtifactsApi .create (str ( filename ) , pulp_domain = "default" )
127124 assert "default/api/v3/" in dup_artifact .pulp_href
128125 assert dup_artifact .sha256 == second_artifact .sha256
129126
@@ -148,9 +145,9 @@ def test_content_upload(
148145 file = generate_iso (filename )
149146 relative_path = "1.iso"
150147
151- task = file_bindings .ContentFilesApi .create (relative_path , file = filename ).task
148+ task = file_bindings .ContentFilesApi .create (relative_path , file = str ( filename ) ).task
152149 task2 = file_bindings .ContentFilesApi .create (
153- relative_path , file = filename , pulp_domain = domain .name
150+ relative_path , file = str ( filename ) , pulp_domain = domain .name
154151 ).task
155152 response = monitor_task (task )
156153 default_content = file_bindings .ContentFilesApi .read (response .created_resources [0 ])
@@ -230,7 +227,7 @@ def test_content_promotion(
230227
231228 # Test that a repository version repair operation can be run without error
232229 response = file_bindings .RepositoriesFileVersionsApi .repair (
233- repo .latest_version_href , Repair (verify_checksums = True )
230+ repo .latest_version_href , file_bindings . Repair (verify_checksums = True )
234231 )
235232 results = monitor_task (response .task )
236233 assert results .state == "completed"
@@ -273,7 +270,7 @@ def test_domain_rbac(pulpcore_bindings, file_bindings, gen_user, gen_object_with
273270 assert repos .count == 1
274271 assert repos .results [0 ].pulp_href == repo .pulp_href
275272 # Try to create a repository in default domain
276- with pytest .raises (ApiException ) as e :
273+ with pytest .raises (file_bindings . ApiException ) as e :
277274 file_bindings .RepositoriesFileApi .create ({"name" : str (uuid .uuid4 ())})
278275 assert e .value .status == 403
279276
@@ -284,7 +281,7 @@ def test_domain_rbac(pulpcore_bindings, file_bindings, gen_user, gen_object_with
284281 repos = file_bindings .RepositoriesFileApi .list ()
285282 assert repos .count == 0
286283 # Try to create a repo
287- with pytest .raises (ApiException ) as e :
284+ with pytest .raises (file_bindings . ApiException ) as e :
288285 file_bindings .RepositoriesFileApi .create (
289286 {"name" : str (uuid .uuid4 ())}, pulp_domain = domain .name
290287 )
0 commit comments