Skip to content

Commit

Permalink
Remove pulp-smash utils
Browse files Browse the repository at this point in the history
closes #804
  • Loading branch information
lubosmj committed Jul 3, 2023
1 parent f99a108 commit d8e7ca2
Show file tree
Hide file tree
Showing 27 changed files with 532 additions and 722 deletions.
1 change: 1 addition & 0 deletions CHANGES/804.misc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Removed pulp-smash utilities.
14 changes: 14 additions & 0 deletions pulp_file/tests/functional/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,20 @@ def file_fixture_server(file_fixtures_root, gen_fixture_server):
return gen_fixture_server(file_fixtures_root, None)


@pytest.fixture
def gen_file_remote(file_fixture_server):
def _gen_file_remote(manifest_path=None, **kwargs):
url = kwargs.get("url")
if not url:
assert manifest_path is not None
url = file_fixture_server.make_url(manifest_path)
data = {"url": url, "name": str(uuid.uuid4())}
data.update(kwargs)
return data

return _gen_file_remote


@pytest.fixture
def file_remote_factory(file_fixture_server, file_remote_api_client, gen_object_with_cleanup):
def _file_remote_factory(*, manifest_path, policy, pulp_domain=None, **body):
Expand Down
118 changes: 0 additions & 118 deletions pulp_file/tests/functional/api/from_pulpcore/constants.py

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,11 @@
PatchedfileFileDistribution,
)

from pulp_file.tests.functional.utils import (
get_redis_status,
get_url,
)
from pulp_file.tests.functional.utils import get_url
from .constants import PULP_CONTENT_BASE_URL

is_redis_connected = get_redis_status()


@pytest.mark.parallel
@pytest.mark.skipif(is_redis_connected is False, reason="Could not connect to the Redis server")
def test_full_workflow(
file_repo_with_auto_publish,
basic_manifest_path,
Expand All @@ -31,7 +25,11 @@ def test_full_workflow(
file_distribution_factory,
gen_object_with_cleanup,
monitor_task,
redis_status,
):
if not redis_status:
pytest.skip("Could not connect to the Redis server")

def _check_cache(url):
"""Helper to check if cache miss or hit"""
r = get_url(url)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,6 @@
import pytest
from urllib.parse import urljoin

from pulp_smash.pulp3.utils import (
gen_distribution,
)

from pulpcore.client.pulp_file import (
RepositorySyncURL,
)
Expand All @@ -24,10 +20,9 @@ def test_delete_remote_on_demand(
file_remote_ssl_factory,
file_remote_api_client,
file_repository_api_client,
file_distribution_api_client,
basic_manifest_path,
gen_object_with_cleanup,
monitor_task,
file_distribution_factory,
):
# Create a remote with on_demand download policy
remote = file_remote_ssl_factory(manifest_path=basic_manifest_path, policy="on_demand")
Expand All @@ -38,9 +33,7 @@ def test_delete_remote_on_demand(
repo = file_repository_api_client.read(file_repo_with_auto_publish.pulp_href)

# Create a distribution pointing to the repository
distribution = gen_object_with_cleanup(
file_distribution_api_client, gen_distribution(repository=repo.pulp_href)
)
distribution = file_distribution_factory(repository=repo.pulp_href)

# Download the manifest from the remote
expected_file_list = list(get_files_in_manifest(remote.url))
Expand Down Expand Up @@ -70,11 +63,10 @@ def test_remote_artifact_url_update(
file_repo_with_auto_publish,
file_remote_ssl_factory,
file_repository_api_client,
file_distribution_api_client,
basic_manifest_path,
basic_manifest_only_path,
gen_object_with_cleanup,
monitor_task,
file_distribution_factory,
):
# Create a remote that points to a repository that only has the manifest, but no content
remote = file_remote_ssl_factory(manifest_path=basic_manifest_only_path, policy="on_demand")
Expand All @@ -85,9 +77,7 @@ def test_remote_artifact_url_update(
repo = file_repository_api_client.read(file_repo_with_auto_publish.pulp_href)

# Create a distribution from the publication
distribution = gen_object_with_cleanup(
file_distribution_api_client, gen_distribution(repository=repo.pulp_href)
)
distribution = file_distribution_factory(repository=repo.pulp_href)

# Download the manifest from the remote
expected_file_list = list(get_files_in_manifest(remote.url))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
import pytest
import uuid

from pulp_smash.pulp3.utils import gen_distribution

from pulpcore.client.pulp_file import (
PatchedfileFileDistribution,
)
Expand All @@ -24,6 +22,7 @@ def test_rbac_content_guard_full_workflow(
gen_user,
gen_object_with_cleanup,
monitor_task,
file_distribution_factory,
):
# Create all of the users and groups
creator_user = gen_user(
Expand All @@ -39,7 +38,7 @@ def test_rbac_content_guard_full_workflow(

# Create a distribution
with creator_user:
distro = gen_object_with_cleanup(file_distribution_api_client, gen_distribution())
distro = file_distribution_factory()

def _assert_access(authorized_users):
"""Asserts that only authorized users have access to the distribution's base_url."""
Expand Down
17 changes: 10 additions & 7 deletions pulp_file/tests/functional/api/from_pulpcore/test_content_path.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,9 @@
import pytest
import uuid

from pulp_smash import utils
from pulp_smash.pulp3.utils import gen_distribution
from urllib.parse import urljoin

from .constants import PULP_CONTENT_BASE_URL
from pulp_file.tests.functional.utils import gen_distribution


@pytest.mark.parallel
Expand All @@ -16,6 +14,8 @@ def test_content_directory_listing(
tls_certificate_authority_cert,
x509_content_guards_api_client,
pulp_settings,
http_get,
pulp_status,
):
"""Checks that distributions are grouped by base-path when listing content directories."""

Expand All @@ -38,20 +38,23 @@ def test_content_directory_listing(
gen_distribution(base_path=base_path + path, content_guard=content_guard),
)

base_url = PULP_CONTENT_BASE_URL
base_url = urljoin(
pulp_status.content_settings.content_origin,
pulp_status.content_settings.content_path_prefix,
)
if pulp_settings.DOMAIN_ENABLED:
base_url = urljoin(base_url, "default/")
response = utils.http_get(base_url).decode("utf-8")
response = http_get(base_url).decode("utf-8")
assert response.count(f'a href="{base_path}/"') == 1
assert response.count('a href="../"') == 0

url = urljoin(base_url, base_path + "/")
response = utils.http_get(url).decode("utf-8")
response = http_get(url).decode("utf-8")
assert response.count('a href="foo1/"') == 1
assert response.count('a href="foo2/"') == (0 if HIDE_GUARDED_DISTRIBUTIONS else 1)
assert response.count('a href="boo1/"') == 1
assert response.count('a href="boo2/"') == (0 if HIDE_GUARDED_DISTRIBUTIONS else 1)
assert response.count('a href="../"') == 1

response = utils.http_get(urljoin(url, "boo1/")).decode("utf-8")
response = http_get(urljoin(url, "boo1/")).decode("utf-8")
assert response.count('a href="foo1/"') == 1
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
import pytest
from urllib.parse import urljoin

from pulp_smash.pulp3.utils import gen_distribution

from pulp_file.tests.functional.utils import (
get_files_in_manifest,
get_url,
Expand All @@ -20,9 +18,8 @@ def test_content_promotion(
file_remote_ssl_factory,
file_repository_api_client,
file_publication_api_client,
file_distribution_api_client,
file_distribution_factory,
basic_manifest_path,
gen_object_with_cleanup,
monitor_task,
):
# Create a repository, publication, and 2 distributions
Expand All @@ -40,19 +37,13 @@ def test_content_promotion(
pub = file_publication_api_client.read(created[1])

# Create two Distributions pointing to the publication
distribution1 = gen_object_with_cleanup(
file_distribution_api_client, gen_distribution(publication=pub.pulp_href)
)
distribution2 = gen_object_with_cleanup(
file_distribution_api_client, gen_distribution(publication=pub.pulp_href)
)
distribution1 = file_distribution_factory(publication=pub.pulp_href)
distribution2 = file_distribution_factory(publication=pub.pulp_href)
assert distribution1.publication == pub.pulp_href
assert distribution2.publication == pub.pulp_href

# Create a Distribution using the repository
distribution3 = gen_object_with_cleanup(
file_distribution_api_client, gen_distribution(repository=file_repo.pulp_href)
)
distribution3 = file_distribution_factory(repository=file_repo.pulp_href)

for distro in [distribution1, distribution2, distribution3]:
# Assert that all 3 distributions can be accessed
Expand Down
Loading

0 comments on commit d8e7ca2

Please sign in to comment.