added new TESTING global param and monkey patch method with new testing input param
@@ -51,6 +51,13 @@ class ObservationsClass(MastQueryWithLogin):
Class for querying MAST observational data.
"""
+ environment = os.environ['CONDA_DEFAULT_ENV']
+
+ if 'test' in environment.lower():
+ TESTING = '.24test'
+ elif 'ops' in environment.lower():
+ TESTING = None
+
def _parse_result(self, responses, verbose=False): # Used by the async_to_sync decorator functionality
"""
Parse the results of a list of `~requests.Response` objects and returns an `~astropy.table.Table` of results.
@@ -71,7 +78,17 @@ class ObservationsClass(MastQueryWithLogin):
return self._portal_api_connection._parse_result(responses, verbose)
- def list_missions(self):
+ def overwrite_service(input_service):
+
+ frame = sys._getframe(1)
+
+ # The input parameter that gets called (`service`) will be overwritten by `input_service`
+ frame.f_locals['service'] = input_service
+
+ ctypes.pythonapi.PyFrame_LocalsToFast(ctypes.py_object(frame),
+ ctypes.c_int(0))
+
+ def list_missions(self, testing=TESTING):
"""
Lists data missions archived by MAST and avaiable through `astroquery.mast`.
@@ -82,7 +99,7 @@ class ObservationsClass(MastQueryWithLogin):
"""
# getting all the histogram information
- service = "Mast.Caom.All"
+ service = "Mast.Caom.All" if testing is None else testing
params = {}
response = self._portal_api_connection.service_request_async(service, params, format='extjs')
json_response = response[0].json()
