From 9109a0d7258858c7e14f0fe3cfaea68a4caa4955 Mon Sep 17 00:00:00 2001 From: Kaiserunix <227545839+Kaiserunix@users.noreply.github.com> Date: Wed, 9 Sep 2026 20:38:10 +0800 Subject: [PATCH] Respect the configured timeout for AQL queries --- artifactory.py | 4 +++- tests/unit/test_artifactory_path.py | 17 +++++++++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/artifactory.py b/artifactory.py index 784ad71..918eb37 100755 --- a/artifactory.py +++ b/artifactory.py @@ -2617,7 +2617,9 @@ def aql(self, *args): aql_query_url = "{}/api/search/aql".format(self.drive.rstrip("/")) aql_query_text = self.create_aql_text(*args) logger.debug(f"AQL query request text: {aql_query_text}") - response = self.session.post(aql_query_url, data=aql_query_text) + response = self.session.post( + aql_query_url, data=aql_query_text, timeout=self.timeout + ) raise_for_status(response) content = response.json() return content["results"] diff --git a/tests/unit/test_artifactory_path.py b/tests/unit/test_artifactory_path.py index 7d14302..a0c84a4 100644 --- a/tests/unit/test_artifactory_path.py +++ b/tests/unit/test_artifactory_path.py @@ -11,6 +11,7 @@ from responses.matchers import json_params_matcher from responses.matchers import query_param_matcher from responses.matchers import query_string_matcher +from responses.matchers import request_kwargs_matcher from urllib3.util import parse_url import artifactory @@ -1652,6 +1653,22 @@ class TestArtifactoryAql(unittest.TestCase): def setUp(self): self.aql = ArtifactoryPath("http://b/artifactory") + def test_aql_request_timeout(self): + for timeout in (None, 5, (2, 5)): + with self.subTest(timeout=timeout), responses.RequestsMock() as mocked: + path = ArtifactoryPath("http://b/artifactory", timeout=timeout) + results = [{"repo": "myrepo", "name": "file.txt"}] + mocked.add( + responses.POST, + "http://b/artifactory/api/search/aql", + json={"results": results}, + match=[request_kwargs_matcher({"timeout": timeout})], + ) + self.assertEqual(path.aql("items.find", {"repo": "myrepo"}), results) + self.assertEqual( + mocked.calls[0].request.body, 'items.find({"repo": "myrepo"})' + ) + def test_create_aql_text_simple(self): args = ["items.find", {"repo": "myrepo"}] aql_text = self.aql.create_aql_text(*args)