Skip to content

Commit 99cb1b9

Browse files
committed
fix(searcher): respect get-file-locations --server parameter (#155)
Fixes issue where `get-file-locations --server https://example.org` would ignore the custom server and revert to the default HTTPS server. Closes #153
1 parent ff4bd39 commit 99cb1b9

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

cernopendata_client/searcher.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ def get_files_list(
201201
if searcher_protocol == "http":
202202
new_server = server
203203
elif searcher_protocol == "https":
204-
new_server = SERVER_HTTPS_URI
204+
new_server = server
205205

206206
for file_ in record_json["metadata"].get("files", []):
207207
files_list.append(
@@ -225,7 +225,7 @@ def get_files_list(
225225
else:
226226
files_list.append(
227227
(
228-
f"{SERVER_HTTPS_URI}/record/{record_json['metadata']['recid']}/file_index/{file_['key']}",
228+
f"{new_server}/record/{record_json['metadata']['recid']}/file_index/{file_['key']}",
229229
file_["size"],
230230
"",
231231
)

tests/test_cli_get_file_locations.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,3 +106,14 @@ def test_get_file_locations_with_https_server_xrootd_protocol():
106106
)
107107
assert test_result.exit_code == 0
108108
assert "root://eospublic.cern.ch//eos/" in test_result.output
109+
110+
111+
def test_get_file_locations_with_custom_https_server():
112+
"""Test `get-file-locations --server` command for custom https server."""
113+
test_get_file_locations = CliRunner()
114+
test_result = test_get_file_locations.invoke(
115+
get_file_locations, ["--recid", 5500, "--server", "https://opendata-qa.cern.ch"]
116+
)
117+
assert test_result.exit_code == 0
118+
assert "https://opendata-qa.cern.ch" in test_result.output
119+
assert "https://opendata.cern.ch" not in test_result.output

0 commit comments

Comments
 (0)