forked from pulp/pulpcore
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adds a pytest local fixture for pulp_file
Required PR: pulp/pulp-smash#1262 closes #9623
- Loading branch information
Showing
11 changed files
with
345 additions
and
66 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Adds pytest fixtures serving an aiohttp.Server to serve pulp_file fixtures to Pulp. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
aiohttp | ||
django | ||
dynaconf | ||
pulp-smash @ git+https://github.com/pulp/pulp-smash.git | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
from .conftest_pulp_file import * # noqa |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,171 @@ | ||
import logging | ||
import uuid | ||
|
||
from pathlib import Path | ||
|
||
import pytest | ||
|
||
from pulpcore.client.pulp_file import ( | ||
ContentFilesApi, | ||
RepositoriesFileApi, | ||
RemotesFileApi, | ||
) | ||
from pulp_smash.pulp3.bindings import monitor_task | ||
from pulp_smash.pulp3.utils import gen_repo | ||
|
||
from pulpcore.tests.functional.api.using_plugin.utils import ( | ||
gen_file_client, | ||
) | ||
|
||
|
||
_logger = logging.getLogger(__name__) | ||
|
||
|
||
@pytest.fixture(scope="session") | ||
def file_client(): | ||
return gen_file_client() | ||
|
||
|
||
@pytest.fixture(scope="session") | ||
def content_file_api_client(file_client): | ||
return ContentFilesApi(file_client) | ||
|
||
|
||
@pytest.fixture(scope="session") | ||
def file_repo_api_client(file_client): | ||
return RepositoriesFileApi(file_client) | ||
|
||
|
||
@pytest.fixture | ||
def file_repo(file_repo_api_client): | ||
repo = file_repo_api_client.create(gen_repo()) | ||
yield repo | ||
task_url = file_repo_api_client.delete(repo.pulp_href).task | ||
monitor_task(task_url) | ||
|
||
|
||
@pytest.fixture(scope="session") | ||
def file_remote_api_client(file_client): | ||
return RemotesFileApi(file_client) | ||
|
||
|
||
@pytest.fixture(scope="session") | ||
def file_fixtures_root(): | ||
return Path(__file__).parent / "fixtures" | ||
|
||
|
||
@pytest.fixture | ||
def assert_no_file_content_pre_test(content_file_api_client): | ||
# Ensure that no content is present | ||
content_response = content_file_api_client.list(limit=1) | ||
assert content_response.count == 0 | ||
|
||
|
||
@pytest.fixture | ||
def file_fixture_server_ssl_client_cert_req( | ||
ssl_ctx_req_client_auth, file_fixtures_root, gen_fixture_server | ||
): | ||
yield gen_fixture_server(file_fixtures_root, ssl_ctx_req_client_auth) | ||
|
||
|
||
@pytest.fixture | ||
def file_fixture_server_ssl(ssl_ctx, file_fixtures_root, gen_fixture_server): | ||
yield gen_fixture_server(file_fixtures_root, ssl_ctx) | ||
|
||
|
||
@pytest.fixture | ||
def file_fixture_server(file_fixtures_root, gen_fixture_server): | ||
yield gen_fixture_server(file_fixtures_root, None) | ||
|
||
|
||
@pytest.fixture | ||
def file_fixture_gen_remote(file_fixture_server, file_remote_api_client): | ||
remotes = [] | ||
|
||
def _file_fixture_gen_remote(*, fixture_name, policy, **kwargs): | ||
host = file_fixture_server.host | ||
port = file_fixture_server.port | ||
url = f"http://{host}:{port}/{fixture_name}/PULP_MANIFEST" | ||
kwargs.update({"url": str(url), "policy": policy, "name": str(uuid.uuid4())}) | ||
new_remote = file_remote_api_client.create(kwargs) | ||
remotes.append(new_remote) | ||
return new_remote | ||
|
||
yield _file_fixture_gen_remote | ||
|
||
task_urls = [] | ||
for remote in remotes: | ||
task_urls.append(file_remote_api_client.delete(remote.pulp_href).task) | ||
|
||
for task_url in task_urls: | ||
monitor_task(task_url) | ||
|
||
|
||
@pytest.fixture | ||
def file_fixture_gen_remote_ssl( | ||
file_fixture_server_ssl, file_remote_api_client, tls_certificate_authority_cert | ||
): | ||
remotes = [] | ||
|
||
def _file_fixture_gen_remote(*, fixture_name, policy, **kwargs): | ||
host = file_fixture_server_ssl.host | ||
port = file_fixture_server_ssl.port | ||
url = f"https://{host}:{port}/{fixture_name}/PULP_MANIFEST" | ||
kwargs.update( | ||
{ | ||
"url": str(url), | ||
"policy": policy, | ||
"name": str(uuid.uuid4()), | ||
"ca_cert": tls_certificate_authority_cert, | ||
} | ||
) | ||
new_remote = file_remote_api_client.create(kwargs) | ||
remotes.append(new_remote) | ||
return new_remote | ||
|
||
yield _file_fixture_gen_remote | ||
|
||
task_urls = [] | ||
for remote in remotes: | ||
task_urls.append(file_remote_api_client.delete(remote.pulp_href).task) | ||
|
||
for task_url in task_urls: | ||
monitor_task(task_url) | ||
|
||
|
||
@pytest.fixture | ||
def file_fixture_gen_remote_client_cert_req( | ||
file_fixture_server_ssl_client_cert_req, | ||
file_remote_api_client, | ||
tls_certificate_authority_cert, | ||
client_tls_certificate_cert_pem, | ||
client_tls_certificate_key_pem, | ||
): | ||
remotes = [] | ||
|
||
def _file_fixture_gen_remote(*, fixture_name, policy, **kwargs): | ||
host = file_fixture_server_ssl_client_cert_req.host | ||
port = file_fixture_server_ssl_client_cert_req.port | ||
url = f"https://{host}:{port}/{fixture_name}/PULP_MANIFEST" | ||
kwargs.update( | ||
{ | ||
"url": str(url), | ||
"policy": policy, | ||
"name": str(uuid.uuid4()), | ||
"ca_cert": tls_certificate_authority_cert, | ||
"client_cert": client_tls_certificate_cert_pem, | ||
"client_key": client_tls_certificate_key_pem, | ||
} | ||
) | ||
new_remote = file_remote_api_client.create(kwargs) | ||
remotes.append(new_remote) | ||
return new_remote | ||
|
||
yield _file_fixture_gen_remote | ||
|
||
task_urls = [] | ||
for remote in remotes: | ||
task_urls.append(file_remote_api_client.delete(remote.pulp_href).task) | ||
|
||
for task_url in task_urls: | ||
monitor_task(task_url) |
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
1.iso,cbd074de731a7a28fc3257769c417dc2f579ac7a9e072423305033a2bed79033,1024 | ||
2.iso,327ac83861f3e3fcaa115ddd7f91f8d796f55bb1013ea1bd1cc377e28e3ee9cf,1024 | ||
3.iso,f18ab30fc5c52fc5206d9f87ee8b5f4adcb1f09ee452920e6e2ee2ba42600651,1024 |
Oops, something went wrong.