Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion artifactory.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
Expand Down
17 changes: 17 additions & 0 deletions tests/unit/test_artifactory_path.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down