Skip to content

Commit

Permalink
Merge pull request #2000 from olyoberdorf/gemini_engineering_fail_req…
Browse files Browse the repository at this point in the history
…uest_support

Allow engineering/qa search terms
  • Loading branch information
bsipocz authored Apr 20, 2021
2 parents d3d5c8e + 3eefa52 commit 4f58dae
Show file tree
Hide file tree
Showing 4 changed files with 62 additions and 4 deletions.
3 changes: 2 additions & 1 deletion CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,8 @@ Gemini
- login() support for authenticated sessions to the GOA [#1778]
- get_file() support for downloading files [#1778]
- fix syntax error in query_criteria() [#1823]

- If QA and/or engineering parameters are explicitly passed, remove the add defaults of `notengineering` and/or
`NotFail` [#1996]

heasarc
^^^^^^^
Expand Down
30 changes: 30 additions & 0 deletions astroquery/gemini/tests/test_gemini.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,3 +117,33 @@ def test_url_helper_coordinates():
kwargs = {"coordinates": "210.80242917 54.348753"}
url = urlh.build_url(*args, **kwargs)
assert url == "https://archive.gemini.edu/jsonsummary/notengineering/NotFail/ra=210.802429/dec=54.348753"


# send arg, should it have notengineering?, should it have NotFail?
eng_fail_tests = [
('notengineering', True, True),
('engineering', False, True),
('includeengineering', False, True),
('NotFail', True, True),
('AnyQA', True, False),
('Pass', True, False),
('Lucky', True, False),
('Win', True, False),
('Usable', True, False),
('Undefind', True, False),
('Fail', True, False),
]


@pytest.mark.parametrize("test_arg", eng_fail_tests)
def test_url_helper_eng_fail(test_arg):
""" test the urlhelper logic around engineering/fail requests/defaults """
urlh = URLHelper()
args = [test_arg[0]]
should_have_noteng = test_arg[1]
should_have_notfail = test_arg[2]
kwargs = {}
url = urlh.build_url(*args, **kwargs)
urlsplit = url.split('/')
assert(('notengineering' in urlsplit) == should_have_noteng)
assert(('NotFail' in urlsplit) == should_have_notfail)
30 changes: 28 additions & 2 deletions astroquery/gemini/urlhelper.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,34 @@ def build_url(self, *args, **kwargs):
-------
response : `string` url to execute the query
"""

url = "%s/jsonsummary/notengineering/NotFail" % self.server
qa_parm = ''
eng_parm = ''

# List of args that specify a QA state
qa_parameters = (
'NotFail',
'AnyQA',
'Pass',
'Lucky',
'Win',
'Usable',
'Undefind',
'Fail'
)

# List of args that specify engineering data (or not)
engineering_parameters = (
'notengineering',
'engineering',
'includeengineering'
)

if not any(eng_parm in args for eng_parm in engineering_parameters):
eng_parm = 'notengineering/'
if not any(qa_parm in args for qa_parm in qa_parameters):
qa_parm = 'NotFail/'
url = "%s/jsonsummary/%s%s" % (self.server, eng_parm, qa_parm)
url = url[:-1] # strip trailing /

for arg in args:
url = "%s/%s" % (url, arg)
Expand Down
3 changes: 2 additions & 1 deletion docs/gemini/gemini.rst
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,8 @@ Gemini website. This call also supports the ``orderby`` kwarg for requesting th
This example is equivalent to doing a web search with
`this example search <https://archive.gemini.edu/searchform/RAW/cols=CTOWEQ/notengineering/GMOS-N/PIname=Hirst/NotFail>`_ .
Note that *NotFail*, *notengineering*, *RAW*, and *cols* are all sent automatically. Only the additional
terms need be passed into the method.
terms need be passed into the method. If QA or engineering search terms are passed, those will replace
the *NotFail* or *notengineering* terms respectively.

.. code-block:: python
Expand Down

0 comments on commit 4f58dae

Please sign in to comment.