forked from pulp/pulp-smash
-
Notifications
You must be signed in to change notification settings - Fork 0
/
utils.py
37 lines (28 loc) · 1.1 KB
/
utils.py
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
# coding=utf-8
"""Utilities for RPM tests."""
from __future__ import unicode_literals
import json
import requests
from pulp_smash import config, selectors, utils
from pulp_smash.constants import RPM_ERRATUM_URL
def set_up_module():
"""Skip tests if the RPM plugin is not installed.
See :mod:`pulp_smash.tests` for more information.
"""
utils.skip_if_type_is_unsupported('rpm')
def gen_erratum():
"""Return an erratum with a randomized ID.
Fetch, decode, munge and return the erratum file at
:data:`pulp_smash.constants.RPM_ERRATUM_URL`. This erratum can be uploaded
and imported into an RPM repository with
:meth:`pulp_smash.utils.upload_import_erratum`.
"""
response = requests.get(RPM_ERRATUM_URL)
response.raise_for_status()
erratum = json.loads(response.text)
erratum['id'] = utils.uuid4()
# "Cannot provide multiple checksums when uploading an erratum"
if selectors.bug_is_untestable(2020, config.get_config().version):
for package in erratum['pkglist'][0]['packages']:
package['sum'] = package['sum'][:2]
return erratum