forked from pulp/pulp_python
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathutils.py
More file actions
61 lines (48 loc) · 1.69 KB
/
Copy pathutils.py
File metadata and controls
61 lines (48 loc) · 1.69 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
import uuid
from pulp_smash import api
from pulp_smash.tests.pulp3 import utils
from pulp_smash.tests.pulp3.constants import REPO_PATH
from pulp_smash.tests.pulp3.utils import gen_repo, sync
from .constants import PYTHON_PROJECT_LIST, PYTHON_CONTENT_PATH, PYTHON_REMOTE_PATH, PYTHON_PYPI_URL
def set_up_module():
""" Skip tests Pulp 3 isn't under test or if pulp-python isn't installed.
"""
utils.require_pulp_3()
utils.require_pulp_plugins({'pulp_python'})
def gen_remote(url):
""" Return a semi-random dict for use in creating an remote.
Arguments:
url (str): The URL to a Python remote repository
"""
return {
'name': str(uuid.uuid4()),
'projects': PYTHON_PROJECT_LIST,
'url': url
}
def gen_publisher():
""" Return a semi-random dict for use in creating a publisher.
"""
return {'name': str(uuid.uuid4())}
def populate_pulp(cfg, url=None):
"""Add python contents to Pulp.
Arguments:
cfg (pulp_smash.config.PulpSmashConfig): Information about a Pulp application.
url (str): The URL to a Python remote repository
Returns:
list: A list of dicts, where each dict describes one python content in Pulp.
"""
if url is None:
url = PYTHON_PYPI_URL
client = api.Client(cfg, api.json_handler)
remote = {}
repo = {}
try:
remote.update(client.post(PYTHON_REMOTE_PATH, gen_remote(url)))
repo.update(client.post(REPO_PATH, gen_repo()))
sync(cfg, remote, repo)
finally:
if remote:
client.delete(remote['_href'])
if repo:
client.delete(repo['_href'])
return client.get(PYTHON_CONTENT_PATH)['results']