Skip to content
Permalink
Browse files

Update tests since file publishers were removed

  • Loading branch information...
daviddavis committed May 13, 2019
1 parent 15e28bf commit d4d582838023fead3f8aeb8cc4067fe09143f5d8
@@ -124,13 +124,9 @@ content in it::
http POST ':24817'$REMOTE_HREF'sync/' repository=$REPO_HREF
sleep 3 # wait for the sync to happen

# Create a FilePublisher
http POST :24817/pulp/api/v3/publishers/file/file/ name=bar
export PUBLISHER_HREF=$(http :24817/pulp/api/v3/publishers/file/file/ | jq -r '.results[] | select(.name == "bar") | ._href')

# Create a Publication
http POST :24817/pulp/api/v3/publications/file/file/ repository=$REPO_HREF publisher=$PUBLISHER_HREF
export PUBLICATION_HREF=$(http :24817/pulp/api/v3/publications/file/file/ | jq -r --arg PUBLISHER_HREF "$PUBLISHER_HREF" '.results[] | select(.publisher==$PUBLISHER_HREF) | ._href')
http POST :24817/pulp/api/v3/publications/file/file/ repository=$REPO_HREF
export PUBLICATION_HREF=$(http :24817/pulp/api/v3/publications/file/file/ | jq -r '.results[0] | ._href')

Now with your :term:`Publication` saved as ``PUBLICATION_HREF`` you can have the
:term:`Distribution` serve it at base_path ``bar``::
@@ -6,7 +6,6 @@
from pulp_smash.pulp3.constants import (
BASE_DISTRIBUTION_PATH,
BASE_PUBLICATION_PATH,
BASE_PUBLISHER_PATH,
BASE_REMOTE_PATH,
CONTENT_PATH
)
@@ -22,8 +21,6 @@

FILE_PUBLICATION_PATH = urljoin(BASE_PUBLICATION_PATH, 'file/file/')

FILE_PUBLISHER_PATH = urljoin(BASE_PUBLISHER_PATH, 'file/file/')

FILE_FIXTURE_URL = urljoin(PULP_FIXTURES_BASE_URL, 'file/')
"""The URL to a file repository."""

@@ -16,7 +16,6 @@
delete_orphans,
download_content_unit,
gen_distribution,
gen_publisher,
gen_repo,
get_content,
sync,
@@ -26,7 +25,6 @@
FILE_CONTENT_NAME,
FILE_DISTRIBUTION_PATH,
FILE_FIXTURE_URL,
FILE_PUBLISHER_PATH,
FILE_REMOTE_PATH,
)
from pulpcore.tests.functional.api.using_plugin.utils import (
@@ -72,10 +70,7 @@ def test_content_remote_delete(self):
sync(cfg, remote, repo)
repo = client.get(repo['_href'])

publisher = client.post(FILE_PUBLISHER_PATH, gen_publisher())
self.addCleanup(client.delete, publisher['_href'])

publication = create_file_publication(cfg, repo, publisher=publisher)
publication = create_file_publication(cfg, repo)
self.addCleanup(client.delete, publication['_href'])

# Delete the remote.
@@ -6,15 +6,13 @@
from pulp_smash.pulp3.constants import REPO_PATH
from pulp_smash.pulp3.utils import (
delete_orphans,
gen_publisher,
gen_remote,
gen_repo,
sync,
)

from pulpcore.tests.functional.api.using_plugin.constants import (
FILE_FIXTURE_MANIFEST_URL,
FILE_PUBLISHER_PATH,
FILE_REMOTE_PATH,
)
from pulpcore.tests.functional.api.using_plugin.utils import ( # noqa:F401
@@ -64,10 +62,7 @@ def test_all(self):
repo = client.post(REPO_PATH, gen_repo())
self.addCleanup(client.delete, repo['_href'])

publisher = client.post(FILE_PUBLISHER_PATH, gen_publisher())
self.addCleanup(client.delete, publisher['_href'])

for _ in range(2):
sync(cfg, remote, repo)
repo = client.get(repo['_href'])
create_file_publication(cfg, repo, publisher=publisher)
create_file_publication(cfg, repo)
@@ -8,7 +8,6 @@
from pulp_smash.pulp3.constants import REPO_PATH
from pulp_smash.pulp3.utils import (
gen_distribution,
gen_publisher,
gen_remote,
gen_repo,
get_added_content,
@@ -19,7 +18,6 @@
FILE_CONTENT_NAME,
FILE_DISTRIBUTION_PATH,
FILE_FIXTURE_MANIFEST_URL,
FILE_PUBLISHER_PATH,
FILE_REMOTE_PATH
)
from pulpcore.tests.functional.api.using_plugin.utils import ( # noqa:F401
@@ -41,7 +39,7 @@ def test_all(self):
Do the following:
1. Create a repository that has at least one repository version.
2. Create a publisher, and publication.
2. Create a publication.
3. Create 2 distributions - using the same publication. Those
distributions will have different ``base_path``.
4. Assert that distributions have the same publication.
@@ -65,10 +63,7 @@ def test_all(self):
sync(cfg, remote, repo)
repo = client.get(repo['_href'])

publisher = client.post(FILE_PUBLISHER_PATH, gen_publisher())
self.addCleanup(client.delete, publisher['_href'])

publication = create_file_publication(cfg, repo, publisher=publisher)
publication = create_file_publication(cfg, repo)
self.addCleanup(client.delete, publication['_href'])

distributions = []
@@ -9,7 +9,6 @@
from pulp_smash.pulp3.constants import REPO_PATH
from pulp_smash.pulp3.utils import (
gen_distribution,
gen_publisher,
gen_repo,
sync
)
@@ -18,7 +17,6 @@
from pulpcore.tests.functional.api.using_plugin.constants import (
FILE_DISTRIBUTION_PATH,
FILE_PUBLICATION_PATH,
FILE_PUBLISHER_PATH,
FILE_REMOTE_PATH
)
from pulpcore.tests.functional.api.using_plugin.utils import (
@@ -39,15 +37,11 @@ def setUpClass(cls):
cls.client = api.Client(cls.cfg, api.page_handler)
cls.remote = {}
cls.publication = {}
cls.publisher = {}
cls.repo = {}
try:
cls.repo.update(cls.client.post(REPO_PATH, gen_repo()))
body = gen_file_remote()
cls.remote.update(cls.client.post(FILE_REMOTE_PATH, body))
cls.publisher.update(
cls.client.post(FILE_PUBLISHER_PATH, gen_publisher())
)
sync(cls.cfg, cls.remote, cls.repo)
except Exception:
cls.tearDownClass()
@@ -56,14 +50,14 @@ def setUpClass(cls):
@classmethod
def tearDownClass(cls):
"""Clean class-wide variables."""
for resource in (cls.remote, cls.publisher, cls.repo):
for resource in (cls.remote, cls.repo):
if resource:
cls.client.delete(resource['_href'])

def test_01_create_file_publication(self):
"""Create a publication."""
self.publication.update(
create_file_publication(self.cfg, self.repo, publisher=self.publisher)
create_file_publication(self.cfg, self.repo)
)

@skip_if(bool, 'publication', False)
@@ -80,7 +74,7 @@ def test_02_read_publication_with_specific_fields(self):
Permutate field list to ensure different combinations on result.
"""
fields = ('_href', '_created', 'distributions', 'publisher')
fields = ('_href', '_created', 'distributions')
for field_pair in permutations(fields, 2):
# ex: field_pair = ('_href', '_created)
with self.subTest(field_pair=field_pair):
@@ -111,17 +105,6 @@ def test_02_read_publications(self):
with self.subTest(key=key):
self.assertEqual(publications[0][key], val)

@skip_if(bool, 'publication', False)
def test_03_read_publications(self):
"""Read a publication by its publisher."""
publications = self.client.get(FILE_PUBLICATION_PATH, params={
'publisher': self.publisher['_href']
})
self.assertEqual(len(publications), 1, publications)
for key, val in self.publication.items():
with self.subTest(key=key):
self.assertEqual(publications[0][key], val)

@skip_if(bool, 'publication', False)
def test_04_read_publications(self):
"""Read a publication by its created time."""
@@ -163,12 +146,11 @@ def test_06_publication_create_order(self):
"""
# Create more 2 publications for the same repo
for _ in range(2):
create_file_publication(self.cfg, self.repo, publisher=self.publisher)
create_file_publication(self.cfg, self.repo)

# Read publications
publications = self.client.get(
FILE_PUBLICATION_PATH,
params={'publisher': self.publisher['_href']}
FILE_PUBLICATION_PATH
)
self.assertEqual(len(publications), 3)

@@ -196,14 +178,3 @@ def test_negative_create_file_remote_with_invalid_parameter(self):
)
assert response.status_code == 400
assert response.json()['foo'] == ['Unexpected field']

def test_negative_create_file_publisher_with_invalid_parameter(self):
"""Attempt to create file publisher passing invalid parameter.
Assert response returns an error 400 including ["Unexpected field"].
"""
response = api.Client(self.cfg, api.echo_handler).post(
FILE_PUBLISHER_PATH, gen_publisher(foo='bar')
)
assert response.status_code == 400
assert response.json()['foo'] == ['Unexpected field']
@@ -12,7 +12,6 @@
from pulp_smash.pulp3.utils import (
delete_orphans,
delete_version,
gen_publisher,
gen_repo,
get_added_content,
get_added_content_summary,
@@ -32,7 +31,6 @@
FILE_FIXTURE_MANIFEST_URL,
FILE_FIXTURE_SUMMARY,
FILE_LARGE_FIXTURE_MANIFEST_URL,
FILE_PUBLISHER_PATH,
FILE_REMOTE_PATH,
)
from pulpcore.tests.functional.api.using_plugin.utils import (
@@ -367,11 +365,7 @@ def test_delete_publication(self):
Delete a repository version, and verify the associated publication is
also deleted.
"""
publisher = self.client.post(FILE_PUBLISHER_PATH, gen_publisher())
self.addCleanup(self.client.delete, publisher['_href'])

publication = create_file_publication(
self.cfg, self.repo, publisher=publisher)
publication = create_file_publication(self.cfg, self.repo)
delete_version(self.repo)

with self.assertRaises(HTTPError):
@@ -1,12 +1,11 @@
# coding=utf-8
"""Tests that perform action over remotes and publishers."""
"""Tests that perform action over remotes"""

import unittest

from pulp_smash import api, config
from pulp_smash.pulp3.constants import REPO_PATH
from pulp_smash.pulp3.utils import (
gen_publisher,
gen_repo,
get_content,
sync,
@@ -15,49 +14,39 @@
from pulpcore.tests.functional.api.using_plugin.constants import (
FILE_CONTENT_NAME,
FILE_REMOTE_PATH,
FILE_PUBLISHER_PATH
)
from pulpcore.tests.functional.api.using_plugin.utils import (
create_file_publication,
gen_file_remote
)
from pulpcore.tests.functional.api.using_plugin.utils import gen_file_remote
from pulpcore.tests.functional.api.using_plugin.utils import set_up_module as setUpModule # noqa


class RemotesPublishersTestCase(unittest.TestCase):
"""Verify publisher and remote can be used with different repos."""
class RemotesTestCase(unittest.TestCase):
"""Verify remotes can be used with different repos."""

def test_all(self):
"""Verify publisher and remote can be used with different repos.
"""Verify remotes can be used with different repos.
This test explores the design choice stated in `Pulp #3341`_ that
remove the FK from publishers and remotes to repository.
Allowing remotes and publishers to be used with different
remove the FK from remotes to repository.
Allowing remotes to be used with different
repositories.
.. _Pulp #3341: https://pulp.plan.io/issues/3341
Do the following:
1. Create a remote, and a publisher.
1. Create a remote.
2. Create 2 repositories.
3. Sync both repositories using the same remote.
4. Assert that the two repositories have the same contents.
5. Publish both repositories using the same publisher.
6. Assert that each generated publication has the same publisher, but
are associated with different repositories.
"""
cfg = config.get_config()

# Create a remote and publisher.
# Create a remote.
client = api.Client(cfg, api.json_handler)
body = gen_file_remote()
remote = client.post(FILE_REMOTE_PATH, body)
self.addCleanup(client.delete, remote['_href'])

publisher = client.post(FILE_PUBLISHER_PATH, gen_publisher())
self.addCleanup(client.delete, publisher['_href'])

# Create and sync repos.
repos = []
for _ in range(2):
@@ -74,16 +63,3 @@ def test_all(self):
{content['_href'] for content in contents[0]},
{content['_href'] for content in contents[1]},
)

# Publish repositories.
publications = []
for repo in repos:
publications.append(create_file_publication(cfg, repo, publisher=publisher))
self.assertEqual(
publications[0]['publisher'],
publications[1]['publisher']
)
self.assertNotEqual(
publications[0]['repository_version'],
publications[1]['repository_version']
)
@@ -72,14 +72,13 @@ def gen_file_remote(url=None, **kwargs):
return gen_remote(url, **kwargs)


def create_file_publication(cfg, repo, version_href=None, publisher=None):
def create_file_publication(cfg, repo, version_href=None):
"""Create a file publication
:param pulp_smash.config.PulpSmashConfig cfg: Information about the Pulp
host.
:param repo: A dict of information about the repository.
:param version_href: A href for the repo version to be published.
:param publisher: A dict of publisher info to use to publish.
:returns: A publication. A dict of information about the just created
publication.
"""
@@ -88,9 +87,6 @@ def create_file_publication(cfg, repo, version_href=None, publisher=None):
else:
body = {"repository": repo["_href"]}

if publisher:
body['publisher'] = publisher['_href']

client = api.Client(cfg, api.json_handler)
call_report = client.post(FILE_PUBLICATION_PATH, body)
tasks = tuple(api.poll_spawned_tasks(cfg, call_report))

0 comments on commit d4d5828

Please sign in to comment.
You can’t perform that action at this time.