From 5e9bacb7d2ddbcc6340b43441db55e755c6fe211 Mon Sep 17 00:00:00 2001 From: Katharina Date: Wed, 3 Feb 2021 13:04:03 +0100 Subject: [PATCH] return globus urls --- pyesgf/search/results.py | 11 +++++++++++ tests/test_results.py | 16 ++++++++++++++++ 2 files changed, 27 insertions(+) diff --git a/pyesgf/search/results.py b/pyesgf/search/results.py index 7ad5970..00a57a3 100644 --- a/pyesgf/search/results.py +++ b/pyesgf/search/results.py @@ -100,6 +100,8 @@ class BaseResult(object): if available :property gridftp_url: The url for downloading the result by Globus if available + :property globus_url: The url for downloading the result by Globus + if available (including endpoint) :property index_node: The index node from where the metadata is stored. Calls to ``*_context()`` will optimise queries to only address this node. @@ -155,6 +157,15 @@ def gridftp_url(self): return url + @property + def globus_url(self): + try: + url, mime = self.urls['Globus'][0] + except (KeyError, IndexError): + return None + + return url + @property def index_node(self): try: diff --git a/tests/test_results.py b/tests/test_results.py index 4a41ba4..c9d87d5 100644 --- a/tests/test_results.py +++ b/tests/test_results.py @@ -87,6 +87,22 @@ def test_gridftp_url_in_file_result(self): assert gridftp_url.split(":")[0] == "gsiftp" assert file_result.gridftp_url.endswith(".nc") + @pytest.mark.slow + def test_globus_url_in_file_result(self): + conn = SearchConnection(self.test_service, distrib=False) + + ctx = conn.new_context(project='CMIP5') + results = ctx.search() + + r1 = results[0] + f_ctx = r1.file_context() + + file_results = f_ctx.search() + for file_result in file_results: + globus_url = file_result.globus_url + assert globus_url.split(":")[0] == "globus" + assert file_result.globus_url.endswith(".nc") + @pytest.mark.slow def test_aggregations(self): conn = SearchConnection(self.test_service, distrib=False)