Skip to content

Commit 052b727

Browse files
committed
Minot fixes
Signed-off-by: Alina Buzachis <[email protected]>
1 parent 6ade18c commit 052b727

File tree

2 files changed

+10
-10
lines changed

2 files changed

+10
-10
lines changed

core/tests/test_controller_helpers.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ def mock_download_failure():
6565
"collection_name, version, expected_uri",
6666
[
6767
(
68-
"another-collection",
68+
"another.collection",
6969
"2.0.0",
7070
(
7171
"http://localhost:44926/api/galaxy/v3/plugin/ansible/content/published/"
@@ -77,7 +77,7 @@ def mock_download_failure():
7777
"0.1.0-beta",
7878
(
7979
"http://localhost:44926/api/galaxy/v3/plugin/ansible/content/published/"
80-
"collections/artifacts/edge.case-0.1.0-beta.tar.gz"
80+
"collections/artifacts/edge-case-0.1.0-beta.tar.gz"
8181
),
8282
),
8383
],
@@ -99,7 +99,7 @@ def test_download_collection_success(mock_download_success):
9999

100100
collection_name = "my_namespace.my_collection"
101101
version = "1.0.0"
102-
expected_path = os.path.join("/mock/temp/dir", "my_namespace-my_collection-1.0.0")
102+
expected_path = os.path.join("/mock/temp/dir", "my_namespace.my_collection-1.0.0")
103103

104104
with download_collection(collection_name, version) as path:
105105
# Assert that the correct path was yielded

core/utils/controller/helpers.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,22 +14,21 @@
1414
logger = logging.getLogger(__name__)
1515

1616

17-
def build_collection_uri(collection: str, version: str) -> str:
17+
def build_collection_uri(collection_name: str, version: str) -> str:
1818
"""
1919
Builds the full URI for a given collection and version.
2020
2121
Args:
22-
collection (str): The collection name.
22+
collection_name (str): The collection name.
2323
version (str): The version string.
2424
2525
Returns:
2626
str: The full URI to the collection artifact.
2727
"""
28+
collection = collection_name.replace(".", "-")
2829
path = "/api/galaxy/v3/plugin/ansible/content/published/collections/artifacts"
2930
filename = f"{collection}-{version}.tar.gz"
3031

31-
print("Filename", filename)
32-
3332
return urljoin(f"{settings.AAP_URL}/", f"{path}/{filename}")
3433

3534

@@ -47,11 +46,10 @@ def download_collection(collection_name: str, version: str) -> Iterator[str]:
4746
The path to the extracted collection files.
4847
"""
4948
response = None
50-
collection = collection_name.replace(".", "-")
5149
temp_base_dir = tempfile.mkdtemp()
52-
collection_path = os.path.join(temp_base_dir, f"{collection}-{version}")
50+
collection_path = os.path.join(temp_base_dir, f"{collection_name}-{version}")
5351
os.makedirs(collection_path, exist_ok=True)
54-
path = build_collection_uri(collection, version)
52+
path = build_collection_uri(collection_name, version)
5553

5654
try:
5755
response = get(path)
@@ -62,4 +60,6 @@ def download_collection(collection_name: str, version: str) -> Iterator[str]:
6260
logger.info(f"Collection extracted to {collection_path}")
6361
yield collection_path # Yield the path to the caller
6462
finally:
63+
if response:
64+
response.close() # Explicitly close the response object
6565
shutil.rmtree(temp_base_dir)

0 commit comments

Comments
 (0)