Skip to content

Commit 4f58dae

Browse files
authored
Merge pull request #2000 from olyoberdorf/gemini_engineering_fail_request_support
Allow engineering/qa search terms
2 parents d3d5c8e + 3eefa52 commit 4f58dae

File tree

4 files changed

+62
-4
lines changed

4 files changed

+62
-4
lines changed

CHANGES.rst

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,8 @@ Gemini
7474
- login() support for authenticated sessions to the GOA [#1778]
7575
- get_file() support for downloading files [#1778]
7676
- fix syntax error in query_criteria() [#1823]
77-
77+
- If QA and/or engineering parameters are explicitly passed, remove the add defaults of `notengineering` and/or
78+
`NotFail` [#1996]
7879

7980
heasarc
8081
^^^^^^^

astroquery/gemini/tests/test_gemini.py

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,3 +117,33 @@ def test_url_helper_coordinates():
117117
kwargs = {"coordinates": "210.80242917 54.348753"}
118118
url = urlh.build_url(*args, **kwargs)
119119
assert url == "https://archive.gemini.edu/jsonsummary/notengineering/NotFail/ra=210.802429/dec=54.348753"
120+
121+
122+
# send arg, should it have notengineering?, should it have NotFail?
123+
eng_fail_tests = [
124+
('notengineering', True, True),
125+
('engineering', False, True),
126+
('includeengineering', False, True),
127+
('NotFail', True, True),
128+
('AnyQA', True, False),
129+
('Pass', True, False),
130+
('Lucky', True, False),
131+
('Win', True, False),
132+
('Usable', True, False),
133+
('Undefind', True, False),
134+
('Fail', True, False),
135+
]
136+
137+
138+
@pytest.mark.parametrize("test_arg", eng_fail_tests)
139+
def test_url_helper_eng_fail(test_arg):
140+
""" test the urlhelper logic around engineering/fail requests/defaults """
141+
urlh = URLHelper()
142+
args = [test_arg[0]]
143+
should_have_noteng = test_arg[1]
144+
should_have_notfail = test_arg[2]
145+
kwargs = {}
146+
url = urlh.build_url(*args, **kwargs)
147+
urlsplit = url.split('/')
148+
assert(('notengineering' in urlsplit) == should_have_noteng)
149+
assert(('NotFail' in urlsplit) == should_have_notfail)

astroquery/gemini/urlhelper.py

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,34 @@ def build_url(self, *args, **kwargs):
7373
-------
7474
response : `string` url to execute the query
7575
"""
76-
77-
url = "%s/jsonsummary/notengineering/NotFail" % self.server
76+
qa_parm = ''
77+
eng_parm = ''
78+
79+
# List of args that specify a QA state
80+
qa_parameters = (
81+
'NotFail',
82+
'AnyQA',
83+
'Pass',
84+
'Lucky',
85+
'Win',
86+
'Usable',
87+
'Undefind',
88+
'Fail'
89+
)
90+
91+
# List of args that specify engineering data (or not)
92+
engineering_parameters = (
93+
'notengineering',
94+
'engineering',
95+
'includeengineering'
96+
)
97+
98+
if not any(eng_parm in args for eng_parm in engineering_parameters):
99+
eng_parm = 'notengineering/'
100+
if not any(qa_parm in args for qa_parm in qa_parameters):
101+
qa_parm = 'NotFail/'
102+
url = "%s/jsonsummary/%s%s" % (self.server, eng_parm, qa_parm)
103+
url = url[:-1] # strip trailing /
78104

79105
for arg in args:
80106
url = "%s/%s" % (url, arg)

docs/gemini/gemini.rst

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,8 @@ Gemini website. This call also supports the ``orderby`` kwarg for requesting th
114114
This example is equivalent to doing a web search with
115115
`this example search <https://archive.gemini.edu/searchform/RAW/cols=CTOWEQ/notengineering/GMOS-N/PIname=Hirst/NotFail>`_ .
116116
Note that *NotFail*, *notengineering*, *RAW*, and *cols* are all sent automatically. Only the additional
117-
terms need be passed into the method.
117+
terms need be passed into the method. If QA or engineering search terms are passed, those will replace
118+
the *NotFail* or *notengineering* terms respectively.
118119

119120
.. code-block:: python
120121

0 commit comments

Comments
 (0)