forked from pulp/pulp_python
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconftest.py
More file actions
94 lines (67 loc) · 2.97 KB
/
Copy pathconftest.py
File metadata and controls
94 lines (67 loc) · 2.97 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
import pytest
from pulp_smash.pulp3.utils import gen_distribution, gen_repo
from pulp_python.tests.functional.utils import gen_python_remote
from pulpcore.client.pulp_python import (
ApiClient,
ContentPackagesApi,
DistributionsPypiApi,
PublicationsPypiApi,
RepositoriesPythonApi,
RemotesPythonApi,
)
# Bindings API Fixtures
@pytest.fixture
def python_bindings_client(cid, bindings_cfg):
"""Provides the python bindings client object."""
api_client = ApiClient(bindings_cfg)
api_client.default_headers["Correlation-ID"] = cid
return api_client
@pytest.fixture
def python_repo_api_client(python_bindings_client):
"""Provides the Python Repository API client object."""
return RepositoriesPythonApi(python_bindings_client)
@pytest.fixture
def python_distro_api_client(python_bindings_client):
"""Provides the Python Distribution API client object."""
return DistributionsPypiApi(python_bindings_client)
@pytest.fixture
def python_content_api_client(python_bindings_client):
"""Provides the Python Package Content API client object."""
return ContentPackagesApi(python_bindings_client)
@pytest.fixture
def python_remote_api_client(python_bindings_client):
"""Provides the Python Remotes API client object."""
return RemotesPythonApi(python_bindings_client)
@pytest.fixture
def python_publication_api_client(python_bindings_client):
"""Proves the Python Publication API client object."""
return PublicationsPypiApi(python_bindings_client)
# Object Generation Fixtures
@pytest.fixture
def python_repo(python_repo_api_client, gen_object_with_cleanup):
"""Creates a Python Repository and deletes it at test cleanup time."""
return gen_object_with_cleanup(python_repo_api_client, gen_repo())
@pytest.fixture
def python_distribution_factory(python_distro_api_client, gen_object_with_cleanup):
"""A factory to generate a Python Distribution with auto-cleanup."""
def _gen_python_distribution(**kwargs):
distro_data = gen_distribution(**kwargs)
return gen_object_with_cleanup(python_distro_api_client, distro_data)
yield _gen_python_distribution
@pytest.fixture
def python_publication_factory(python_publication_api_client, gen_object_with_cleanup):
"""A factory to generate a Python Publication with auto-cleanup."""
def _gen_python_publication(repository, version=None):
if version:
body = {"repository_version": f"{repository.versions_href}{version}/"}
else:
body = {"repository": repository.pulp_href}
return gen_object_with_cleanup(python_publication_api_client, body)
yield _gen_python_publication
@pytest.fixture
def python_remote_factory(python_remote_api_client, gen_object_with_cleanup):
"""A factory to generate a Python Remote with auto-cleanup."""
def _gen_python_remote(**kwargs):
body = gen_python_remote(**kwargs)
return gen_object_with_cleanup(python_remote_api_client, body)
yield _gen_python_remote