Skip to content

Commit

Permalink
increment galaxykit usage
Browse files Browse the repository at this point in the history
No-Issue
  • Loading branch information
chr-stian committed Dec 18, 2023
1 parent f9240a1 commit bcd4c7b
Show file tree
Hide file tree
Showing 2 changed files with 98 additions and 156 deletions.
29 changes: 10 additions & 19 deletions galaxy_ng/tests/integration/api/test_artifact_download.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,15 @@
import logging
import subprocess
import tempfile
from unittest.mock import patch

import pytest
from orionutils.generator import build_collection, randstr

from galaxykit.collections import upload_artifact
from galaxykit.utils import GalaxyClientError, wait_for_task
from galaxykit.utils import wait_for_task
from ..conftest import is_hub_4_5
from ..constants import USERNAME_PUBLISHER
from ..utils import (
CapturingGalaxyError,
CollectionInspector,
get_client,
set_certification,
Expand All @@ -25,7 +23,7 @@
@pytest.mark.installer_smoke_test
def test_download_artifact(ansible_config, galaxy_client):
gc = galaxy_client("partner_engineer")

api_client = get_client(ansible_config("partner_engineer"))
# create, upload and certify a collection
namespace = USERNAME_PUBLISHER
name = f"{USERNAME_PUBLISHER}_{randstr(8)}"
Expand All @@ -40,12 +38,8 @@ def test_download_artifact(ansible_config, galaxy_client):
resp = wait_for_task(gc, resp)
assert resp["state"] == "completed"
hub_4_5 = is_hub_4_5(ansible_config)
# TODO
set_certification(api_client, gc, artifact, hub_4_5=hub_4_5)

# download collection
config = ansible_config("basic_user")

with tempfile.TemporaryDirectory() as dir:
filename = f"{namespace}-{name}-{version}.tar.gz"
tarball_path = f"{dir}/{filename}"
Expand Down Expand Up @@ -79,24 +73,21 @@ def test_download_artifact(ansible_config, galaxy_client):
# TODO: make download logic more DRY in these tests
@pytest.mark.min_hub_version("4.6dev")
@pytest.mark.all
def test_download_artifact_validated(ansible_config, artifact, upload_artifact, galaxy_client):
config = ansible_config("partner_engineer")
api_client = get_client(config, request_token=True, require_auth=True)
def test_download_artifact_validated(ansible_config, galaxy_client, artifact):
gc = galaxy_client("partner_engineer")
api_client = get_client(ansible_config("partner_engineer"))

resp = upload_artifact(config, api_client, artifact)
wait_for_task(api_client, resp)
resp = upload_artifact(None, gc, artifact)
logger.debug("Waiting for upload to be completed")
resp = wait_for_task(gc, resp)
assert resp["state"] == "completed"

set_certification(api_client, gc, artifact, level="validated")

# download collection
config = ansible_config("basic_user")

with tempfile.TemporaryDirectory() as dir:
api_root = config["url"]
filename = f"{artifact.namespace}-{artifact.name}-{artifact.version}.tar.gz"
tarball_path = f"{dir}/{filename}"
url = f"{api_root}v3/plugin/ansible/content/validated/collections/artifacts/{filename}"
url = f"{gc.galaxy_root}v3/plugin/ansible/content/validated/collections/artifacts/{filename}"

cmd = [
"curl",
Expand All @@ -106,7 +97,7 @@ def test_download_artifact_validated(ansible_config, artifact, upload_artifact,
"-H",
"'Content-Type: application/json'",
"-u",
f"{config['username']}:{config['password']}",
f"{gc.username}:{gc.password}",
"-o",
tarball_path,
url,
Expand Down
Loading

0 comments on commit bcd4c7b

Please sign in to comment.