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
6 changes: 2 additions & 4 deletions cernopendata_client/searcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -198,10 +198,8 @@ def get_files_list(
files_list = []

new_server = SERVER_ROOT_URI
if searcher_protocol == "http":
if searcher_protocol in ("http", "https"):
new_server = server
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is the same as line 202, isn't it? Change the if condition to match both http and https?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yup, fixed 😉

elif searcher_protocol == "https":
new_server = SERVER_HTTPS_URI

for file_ in record_json["metadata"].get("files", []):
files_list.append(
Expand Down Expand Up @@ -262,7 +260,7 @@ def get_file_info_remote(server, recid, protocol=None, filtered_files=None):
if searcher_protocol == "http":
file_uri = file_info["uri"].replace(SERVER_ROOT_URI, server)
elif searcher_protocol == "https":
file_uri = file_info["uri"].replace(SERVER_ROOT_URI, SERVER_HTTPS_URI)
file_uri = file_info["uri"].replace(SERVER_ROOT_URI, server)
if not filtered_files or file_uri in filtered_files:
file_info_remote.append(
{
Expand Down
14 changes: 13 additions & 1 deletion tests/test_cli_get_file_locations.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#
# This file is part of cernopendata-client.
#
# Copyright (C) 2020 CERN.
# Copyright (C) 2020, 2025 CERN.
#
# cernopendata-client is free software; you can redistribute it and/or modify
# it under the terms of the GPLv3 license; see LICENSE file for more details.
Expand Down Expand Up @@ -130,3 +130,15 @@ def test_get_file_locations_no_expand_with_http_protocol():
assert test_result.exit_code == 0
assert "http://opendata.cern.ch" in test_result.output
assert "file_index" in test_result.output


def test_get_file_locations_with_custom_https_server():
"""Test `get-file-locations --server` command for custom https server."""
test_get_file_locations = CliRunner()
test_result = test_get_file_locations.invoke(
get_file_locations, ["--recid", 3005, "--server", "https://opendata-qa.cern.ch"]
)
assert test_result.exit_code == 0
assert "https://opendata-qa.cern.ch" in test_result.output
assert "https://opendata.cern.ch" not in test_result.output
assert "configFile.py" in test_result.output