Skip to content

Commit

Permalink
Renames importer to remote in tests
Browse files Browse the repository at this point in the history
  • Loading branch information
dkliban authored and Ichimonji10 committed Apr 6, 2018
1 parent f50c0bf commit f93f19a
Show file tree
Hide file tree
Showing 13 changed files with 212 additions and 212 deletions.
2 changes: 1 addition & 1 deletion docs/api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ developers, not a gospel.
api/pulp_smash.tests.pulp3.file.api_v3.test_crd_artifacts
api/pulp_smash.tests.pulp3.file.api_v3.test_crd_publications
api/pulp_smash.tests.pulp3.file.api_v3.test_crud_content_unit
api/pulp_smash.tests.pulp3.file.api_v3.test_crud_importers
api/pulp_smash.tests.pulp3.file.api_v3.test_crud_remotes
api/pulp_smash.tests.pulp3.file.api_v3.test_crud_publishers
api/pulp_smash.tests.pulp3.file.api_v3.test_download_content
api/pulp_smash.tests.pulp3.file.api_v3.test_publish
Expand Down
20 changes: 10 additions & 10 deletions pulp_smash/tests/pulp3/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

ARTIFACTS_PATH = urljoin(BASE_PATH, 'artifacts/')

BASE_IMPORTER_PATH = urljoin(BASE_PATH, 'importers/')
BASE_REMOTE_PATH = urljoin(BASE_PATH, 'remotes/')

BASE_PUBLISHER_PATH = urljoin(BASE_PATH, 'publishers/')

Expand All @@ -17,22 +17,22 @@

FILE_CONTENT_PATH = urljoin(CONTENT_PATH, 'file/')

FILE_IMPORTER_PATH = urljoin(BASE_IMPORTER_PATH, 'file/')
FILE_REMOTE_PATH = urljoin(BASE_REMOTE_PATH, 'file/')

FILE_PUBLISHER_PATH = urljoin(BASE_PUBLISHER_PATH, 'file/')

IMPORTER_DOWN_POLICY = {'background', 'immediate', 'on_demand'}
"""Download policies for an importer.
REMOTE_DOWN_POLICY = {'background', 'immediate', 'on_demand'}
"""Download policies for an remote.
See `pulpcore.app.models.Importer
<https://docs.pulpproject.org/en/3.0/nightly/contributing/platform_api/app/models.html#pulpcore.app.models.Importer>`_.
See `pulpcore.app.models.Remote
<https://docs.pulpproject.org/en/3.0/nightly/contributing/platform_api/app/models.html#pulpcore.app.models.Remote>`_.
"""

IMPORTER_SYNC_MODE = {'mirror'}
"""Sync modes for an importer.
REMOTE_SYNC_MODE = {'mirror'}
"""Sync modes for an remote.
See `pulpcore.app.models.Importer
<https://docs.pulpproject.org/en/3.0/nightly/contributing/platform_api/app/models.html#pulpcore.app.models.Importer>`_.
See `pulpcore.app.models.Remote
<https://docs.pulpproject.org/en/3.0/nightly/contributing/platform_api/app/models.html#pulpcore.app.models.Remote>`_.
"""

JWT_PATH = urljoin(BASE_PATH, 'jwt/')
Expand Down
14 changes: 7 additions & 7 deletions pulp_smash/tests/pulp3/file/api_v3/test_crd_publications.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@
from pulp_smash.constants import FILE_FEED_URL
from pulp_smash.tests.pulp3.constants import (
FILE_PUBLISHER_PATH,
FILE_IMPORTER_PATH,
FILE_REMOTE_PATH,
PUBLICATIONS_PATH,
REPO_PATH,
)
from pulp_smash.tests.pulp3.file.api_v3.utils import (
gen_importer,
gen_remote,
gen_publisher,
)
from pulp_smash.tests.pulp3.file.utils import set_up_module as setUpModule # noqa pylint:disable=unused-import
Expand All @@ -31,27 +31,27 @@ def setUpClass(cls):
cls.cfg = config.get_config()
cls.client = api.Client(cls.cfg, api.json_handler)
cls.client.request_kwargs['auth'] = get_auth()
cls.importer = {}
cls.remote = {}
cls.publication = {}
cls.publisher = {}
cls.repo = {}
try:
cls.repo.update(cls.client.post(REPO_PATH, gen_repo()))
body = gen_importer()
body = gen_remote()
body['feed_url'] = urljoin(FILE_FEED_URL, 'PULP_MANIFEST')
cls.importer.update(cls.client.post(FILE_IMPORTER_PATH, body))
cls.remote.update(cls.client.post(FILE_REMOTE_PATH, body))
cls.publisher.update(
cls.client.post(FILE_PUBLISHER_PATH, gen_publisher())
)
sync_repo(cls.cfg, cls.importer, cls.repo)
sync_repo(cls.cfg, cls.remote, cls.repo)
except: # noqa:E722
cls.tearDownClass()
raise

@classmethod
def tearDownClass(cls):
"""Clean class-wide variables."""
for resource in (cls.importer, cls.publisher, cls.repo):
for resource in (cls.remote, cls.publisher, cls.repo):
if resource:
cls.client.delete(resource['_href'])

Expand Down
12 changes: 6 additions & 6 deletions pulp_smash/tests/pulp3/file/api_v3/test_crud_content_unit.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@
from pulp_smash.tests.pulp3.constants import (
ARTIFACTS_PATH,
FILE_CONTENT_PATH,
FILE_IMPORTER_PATH,
FILE_REMOTE_PATH,
REPO_PATH,
)
from pulp_smash.tests.pulp3.file.api_v3.utils import gen_importer
from pulp_smash.tests.pulp3.file.api_v3.utils import gen_remote
from pulp_smash.tests.pulp3.file.utils import set_up_module as setUpModule # noqa pylint:disable=unused-import
from pulp_smash.tests.pulp3.pulpcore.utils import gen_repo
from pulp_smash.tests.pulp3.utils import (
Expand Down Expand Up @@ -126,13 +126,13 @@ def test_all(self):
cfg = config.get_config()
client = api.Client(cfg, api.json_handler)
client.request_kwargs['auth'] = get_auth()
body = gen_importer()
body = gen_remote()
body['feed_url'] = urljoin(FILE_FEED_URL, 'PULP_MANIFEST')
importer = client.post(FILE_IMPORTER_PATH, body)
self.addCleanup(client.delete, importer['_href'])
remote = client.post(FILE_REMOTE_PATH, body)
self.addCleanup(client.delete, remote['_href'])
repo = client.post(REPO_PATH, gen_repo())
self.addCleanup(client.delete, repo['_href'])
sync_repo(cfg, importer, repo)
sync_repo(cfg, remote, repo)
repo = client.get(repo['_href'])
content = get_content(repo)['results']
with self.assertRaises(HTTPError):
Expand Down
115 changes: 0 additions & 115 deletions pulp_smash/tests/pulp3/file/api_v3/test_crud_importers.py

This file was deleted.

115 changes: 115 additions & 0 deletions pulp_smash/tests/pulp3/file/api_v3/test_crud_remotes.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
# coding=utf-8
"""Tests that CRUD remotes."""
import random
import unittest

from requests.exceptions import HTTPError

from pulp_smash import api, config, selectors, utils
from pulp_smash.constants import FILE_FEED_URL, FILE2_FEED_URL
from pulp_smash.tests.pulp3.constants import FILE_REMOTE_PATH, REPO_PATH
from pulp_smash.tests.pulp3.file.api_v3.utils import gen_remote
from pulp_smash.tests.pulp3.file.utils import set_up_module as setUpModule # noqa pylint:disable=unused-import
from pulp_smash.tests.pulp3.pulpcore.utils import gen_repo
from pulp_smash.tests.pulp3.utils import get_auth


class CRUDRemotesTestCase(unittest.TestCase, utils.SmokeTest):
"""CRUD remotes."""

@classmethod
def setUpClass(cls):
"""Create class-wide variables.
In order to create an remote a repository has to be created first.
"""
cls.cfg = config.get_config()
cls.client = api.Client(cls.cfg, api.json_handler)
cls.client.request_kwargs['auth'] = get_auth()
cls.remote = {}
cls.repo = cls.client.post(REPO_PATH, gen_repo())

@classmethod
def tearDownClass(cls):
"""Clean class-wide variable."""
cls.client.delete(cls.repo['_href'])

def test_01_create_remote(self):
"""Create an remote."""
body = _gen_verbose_remote()
type(self).remote = self.client.post(FILE_REMOTE_PATH, body)
for key in ('username', 'password'):
del body[key]
for key, val in body.items():
with self.subTest(key=key):
self.assertEqual(self.remote[key], val)

@selectors.skip_if(bool, 'remote', False)
def test_02_read_remote(self):
"""Read an remote by its href."""
remote = self.client.get(self.remote['_href'])
for key, val in self.remote.items():
with self.subTest(key=key):
self.assertEqual(remote[key], val)

@selectors.skip_if(bool, 'remote', False)
def test_02_read_remotes(self):
"""Read an remote by its name."""
page = self.client.get(FILE_REMOTE_PATH, params={
'name': self.remote['name']
})
self.assertEqual(len(page['results']), 1)
for key, val in self.remote.items():
with self.subTest(key=key):
self.assertEqual(page['results'][0][key], val)

@selectors.skip_if(bool, 'remote', False)
def test_03_partially_update(self):
"""Update an remote using HTTP PATCH."""
body = _gen_verbose_remote()
self.client.patch(self.remote['_href'], body)
for key in ('username', 'password'):
del body[key]
type(self).remote = self.client.get(self.remote['_href'])
for key, val in body.items():
with self.subTest(key=key):
self.assertEqual(self.remote[key], val)

@selectors.skip_if(bool, 'remote', False)
def test_04_fully_update(self):
"""Update an remote using HTTP PUT."""
body = _gen_verbose_remote()
self.client.put(self.remote['_href'], body)
for key in ('username', 'password'):
del body[key]
type(self).remote = self.client.get(self.remote['_href'])
for key, val in body.items():
with self.subTest(key=key):
self.assertEqual(self.remote[key], val)

@selectors.skip_if(bool, 'remote', False)
def test_05_delete(self):
"""Delete an remote."""
self.client.delete(self.remote['_href'])
with self.assertRaises(HTTPError):
self.client.get(self.remote['_href'])


def _gen_verbose_remote():
"""Return a semi-random dict for use in defining an remote.
For most tests, it's desirable to create remotes with as few attributes
as possible, so that the tests can specifically target and attempt to break
specific features. This module specifically targets remotes, so it makes
sense to provide as many attributes as possible.
Note that 'username' and 'password' are write-only attributes.
"""
attrs = gen_remote()
attrs.update({
'feed_url': random.choice((FILE_FEED_URL, FILE2_FEED_URL)),
'password': utils.uuid4(),
'username': utils.uuid4(),
'validate': random.choice((False, True)),
})
return attrs
12 changes: 6 additions & 6 deletions pulp_smash/tests/pulp3/file/api_v3/test_download_content.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@
from pulp_smash.constants import FILE_FEED_URL, FILE_URL
from pulp_smash.tests.pulp3.constants import (
DISTRIBUTION_PATH,
FILE_IMPORTER_PATH,
FILE_REMOTE_PATH,
FILE_PUBLISHER_PATH,
REPO_PATH,
)
from pulp_smash.tests.pulp3.file.api_v3.utils import (
gen_importer,
gen_remote,
gen_publisher,
)
from pulp_smash.tests.pulp3.file.utils import set_up_module as setUpModule # noqa pylint:disable=unused-import
Expand Down Expand Up @@ -64,11 +64,11 @@ def test_all(self):
client.request_kwargs['auth'] = get_auth()
repo = client.post(REPO_PATH, gen_repo())
self.addCleanup(client.delete, repo['_href'])
body = gen_importer()
body = gen_remote()
body['feed_url'] = urljoin(FILE_FEED_URL, 'PULP_MANIFEST')
importer = client.post(FILE_IMPORTER_PATH, body)
self.addCleanup(client.delete, importer['_href'])
sync_repo(cfg, importer, repo)
remote = client.post(FILE_REMOTE_PATH, body)
self.addCleanup(client.delete, remote['_href'])
sync_repo(cfg, remote, repo)
repo = client.get(repo['_href'])

# Create a publisher.
Expand Down
Loading

0 comments on commit f93f19a

Please sign in to comment.