Skip to content

Commit

Permalink
Make signed_artifact fixture idempotent
Browse files Browse the repository at this point in the history
[noissue]
  • Loading branch information
mdellweg authored and dralley committed Sep 29, 2023
1 parent 26d9ecb commit f6ad825
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions pulp_rpm/tests/functional/conftest.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import hashlib
import json
import uuid
from tempfile import NamedTemporaryFile
Expand Down Expand Up @@ -109,10 +110,17 @@ def rpm_copy_api(rpm_client):


@pytest.fixture
def signed_artifact(http_get, artifacts_api_client, gen_object_with_cleanup, tmp_path):
def signed_artifact(http_get, artifacts_api_client, tmp_path):
data = http_get(RPM_SIGNED_URL)
artifacts = artifacts_api_client.list(sha256=hashlib.sha256(data).hexdigest(), limit=1)
try:
return artifacts.results[0].to_dict()
except IndexError:
pass

temp_file = tmp_path / str(uuid.uuid4())
temp_file.write_bytes(http_get(RPM_SIGNED_URL))
return gen_object_with_cleanup(artifacts_api_client, temp_file).to_dict()
temp_file.write_bytes(data)
return artifacts_api_client.create(temp_file).to_dict()


@pytest.fixture
Expand Down

0 comments on commit f6ad825

Please sign in to comment.