Skip to content

Commit

Permalink
Merge pull request #54 from dralley/master
Browse files Browse the repository at this point in the history
Sync up with the last 2 weeks of smash test changes
  • Loading branch information
daviddavis committed Sep 11, 2018
2 parents 508c4ff + b2e9070 commit ccb8f44
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 146 deletions.
129 changes: 0 additions & 129 deletions pulp_ansible/tests/functional/api/test_crd_publications.py

This file was deleted.

22 changes: 8 additions & 14 deletions pulp_ansible/tests/functional/api/test_crud_content_unit.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,11 @@
ANSIBLE_ROLE_CONTENT_PATH,
ANSIBLE_REMOTE_PATH,
)
from pulp_ansible.tests.functional.utils import gen_ansible_remote, skip_if
from pulp_ansible.tests.functional.utils import (
gen_ansible_content_attrs,
gen_ansible_remote,
skip_if
)
from pulp_ansible.tests.functional.utils import set_up_module as setUpModule # noqa:F401


Expand Down Expand Up @@ -51,7 +55,7 @@ def tearDownClass(cls):

def test_01_create_content_unit(self):
"""Create content unit."""
attrs = _gen_content_unit_attrs(self.artifact)
attrs = gen_ansible_content_attrs(self.artifact)
self.content_unit.update(self.client.post(ANSIBLE_ROLE_CONTENT_PATH, attrs))
for key, val in attrs.items():
with self.subTest(key=key):
Expand Down Expand Up @@ -84,7 +88,7 @@ def test_03_partially_update(self):
This HTTP method is not supported and a HTTP exception is expected.
"""
attrs = _gen_content_unit_attrs(self.artifact)
attrs = gen_ansible_content_attrs(self.artifact)
with self.assertRaises(HTTPError):
self.client.patch(self.content_unit['_href'], attrs)

Expand All @@ -94,21 +98,11 @@ def test_03_fully_update(self):
This HTTP method is not supported and a HTTP exception is expected.
"""
attrs = _gen_content_unit_attrs(self.artifact)
attrs = gen_ansible_content_attrs(self.artifact)
with self.assertRaises(HTTPError):
self.client.put(self.content_unit['_href'], attrs)


def _gen_content_unit_attrs(artifact):
"""Generate a dict with content unit attributes.
:param: artifact: A dict of info about the artifact.
:returns: A semi-random dict for use in creating a content unit.
"""
# FIXME: add content specific metadata here
return {'artifact': artifact['_href']}


@unittest.skip("FIXME: re-enable me later")
class DeleteContentUnitRepoVersionTestCase(unittest.TestCase):
"""Test whether content unit used by a repo version can be deleted.
Expand Down
4 changes: 2 additions & 2 deletions pulp_ansible/tests/functional/api/test_download_content.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
from pulp_ansible.tests.functional.utils import (
gen_ansible_remote,
gen_ansible_publisher,
get_ansible_content_unit_paths,
get_ansible_content_paths,
)
from pulp_ansible.tests.functional.constants import (
ANSIBLE_FIXTURE_URL,
Expand Down Expand Up @@ -85,7 +85,7 @@ def test_all(self):
self.addCleanup(client.delete, distribution['_href'])

# Pick a content unit, and download it from both Pulp Fixtures…
unit_path = choice(get_ansible_content_unit_paths(repo))
unit_path = choice(get_ansible_content_paths(repo))
fixtures_hash = hashlib.sha256(
utils.http_get(urljoin(ANSIBLE_FIXTURE_URL, unit_path))
).hexdigest()
Expand Down
12 changes: 11 additions & 1 deletion pulp_ansible/tests/functional/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def gen_ansible_publisher(**kwargs):
return gen_publisher(**kwargs)


def get_ansible_content_unit_paths(repo):
def get_ansible_content_paths(repo):
"""Return the relative path of content units present in an ansible repository.
:param repo: A dict of information about the repository.
Expand All @@ -56,6 +56,16 @@ def get_ansible_content_unit_paths(repo):
return [content_unit['relative_path'] for content_unit in get_content(repo)]


def gen_ansible_content_attrs(artifact):
"""Generate a dict with content unit attributes.
:param: artifact: A dict of info about the artifact.
:returns: A semi-random dict for use in creating a content unit.
"""
# FIXME: add content specific metadata here
return {'artifact': artifact['_href']}


def populate_pulp(cfg, url=ANSIBLE_FIXTURE_URL):
"""Add ansible contents to Pulp.
Expand Down

0 comments on commit ccb8f44

Please sign in to comment.