Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Remove temporary Nexus data for stale or failed requests that used "pip" as a package manager. Signed-off-by: Athos Ribeiro <athos@redhat.com>
- Loading branch information
1 parent
8be43c9
commit 925bcf6
Showing
3 changed files
with
47 additions
and
8 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,19 @@ | ||
# SPDX-License-Identifier: GPL-3.0-or-later | ||
from cachito.workers import nexus | ||
from cachito.workers.pkg_managers.pip import ( | ||
get_pypi_hosted_repo_name, | ||
get_raw_hosted_repo_name, | ||
get_hosted_repositories_username, | ||
) | ||
from cachito.workers.tasks.celery import app | ||
|
||
|
||
@app.task | ||
def cleanup_pip_request(request_id): | ||
"""Clean up the Nexus Python content for the Cachito request.""" | ||
payload = { | ||
"pip_repository_name": get_pypi_hosted_repo_name(request_id), | ||
"raw_repository_name": get_raw_hosted_repo_name(request_id), | ||
"username": get_hosted_repositories_username(request_id), | ||
} | ||
nexus.execute_script("pip_cleanup", payload) |
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,16 @@ | ||
# SPDX-License-Identifier: GPL-3.0-or-later | ||
from unittest import mock | ||
|
||
from cachito.workers.tasks import pip | ||
|
||
|
||
@mock.patch("cachito.workers.tasks.pip.nexus.execute_script") | ||
def test_cleanup_pip_request(mock_exec_script): | ||
pip.cleanup_pip_request(42) | ||
|
||
expected_payload = { | ||
"pip_repository_name": "cachito-pip-hosted-42", | ||
"raw_repository_name": "cachito-pip-raw-42", | ||
"username": "cachito-pip-42", | ||
} | ||
mock_exec_script.assert_called_once_with("pip_cleanup", expected_payload) |