Repository: spacetelescope/jwql

Issue:
Switch to astroquery.Mast test base url
The archive has removed rehearsal data from their OPS environment(s) in preparation for JWST commissioning.  This causes our nominal `astroquery.mast` queries to return no data.  There is a backend attribute to the `Mast` class that we can use to switch to a different test archive area that contains the rehearsal data. 


Discussion:

Resolving patch:
diff --git a/jwql/edb/engineering_database.py b/jwql/edb/engineering_database.py
--- a/jwql/edb/engineering_database.py
+++ b/jwql/edb/engineering_database.py
@@ -45,6 +45,7 @@
 
 from collections import OrderedDict
 from datetime import datetime
+import os
 import warnings
 
 from astropy.table import Table
@@ -56,10 +57,16 @@
 
 from jwst.lib.engdb_tools import ENGDB_Service
 from jwql.utils.credentials import get_mast_base_url, get_mast_token
+from jwql.utils.utils import get_config
 
 MAST_EDB_MNEMONIC_SERVICE = 'Mast.JwstEdb.Mnemonics'
 MAST_EDB_DICTIONARY_SERVICE = 'Mast.JwstEdb.Dictionary'
 
+# Temporary until JWST operations: switch to test string for MAST request URL
+ON_GITHUB_ACTIONS = '/home/runner' in os.path.expanduser('~') or '/Users/runner' in os.path.expanduser('~')
+if not ON_GITHUB_ACTIONS:
+    Mast._portal_api_connection.MAST_REQUEST_URL = get_config()['mast_request_url']
+
 
 class EdbMnemonic:
     """Class to hold and manipulate results of DMS EngDB queries."""
diff --git a/jwql/jwql_monitors/monitor_mast.py b/jwql/jwql_monitors/monitor_mast.py
--- a/jwql/jwql_monitors/monitor_mast.py
+++ b/jwql/jwql_monitors/monitor_mast.py
@@ -34,6 +34,12 @@
 from jwql.utils.plotting import bar_chart
 
 
+# Temporary until JWST operations: switch to test string for MAST request URL
+ON_GITHUB_ACTIONS = '/home/runner' in os.path.expanduser('~') or '/Users/runner' in os.path.expanduser('~')
+if not ON_GITHUB_ACTIONS:
+    Mast._portal_api_connection.MAST_REQUEST_URL = get_config()['mast_request_url']
+
+
 def instrument_inventory(instrument, dataproduct=JWST_DATAPRODUCTS,
                          add_filters=None, add_requests=None,
                          caom=False, return_data=False):
diff --git a/jwql/website/apps/jwql/data_containers.py b/jwql/website/apps/jwql/data_containers.py
--- a/jwql/website/apps/jwql/data_containers.py
+++ b/jwql/website/apps/jwql/data_containers.py
@@ -41,7 +41,7 @@
 from jwql.edb.engineering_database import get_mnemonic, get_mnemonic_info
 from jwql.instrument_monitors.miri_monitors.data_trending import dashboard as miri_dash
 from jwql.instrument_monitors.nirspec_monitors.data_trending import dashboard as nirspec_dash
-from jwql.utils.utils import ensure_dir_exists, filesystem_path, filename_parser
+from jwql.utils.utils import ensure_dir_exists, filesystem_path, filename_parser, get_config
 from jwql.utils.constants import MONITORS
 from jwql.utils.constants import INSTRUMENT_SERVICE_MATCH, JWST_INSTRUMENT_NAMES_MIXEDCASE, JWST_INSTRUMENT_NAMES_SHORTHAND
 from jwql.utils.preview_image import PreviewImage
@@ -76,6 +76,10 @@
 PACKAGE_DIR = os.path.dirname(__location__.split('website')[0])
 REPO_DIR = os.path.split(PACKAGE_DIR)[0]
 
+# Temporary until JWST operations: switch to test string for MAST request URL
+if not ON_GITHUB_ACTIONS:
+    Mast._portal_api_connection.MAST_REQUEST_URL = get_config()['mast_request_url']
+
 
 def build_table(tablename):
     """Create Pandas dataframe from JWQLDB table.


Test patch:
diff --git a/jwql/tests/test_dark_monitor.py b/jwql/tests/test_dark_monitor.py
--- a/jwql/tests/test_dark_monitor.py
+++ b/jwql/tests/test_dark_monitor.py
@@ -72,6 +72,7 @@ def test_get_metadata():
     assert monitor.frame_time == 10.5
 
 
+@pytest.mark.skipif(ON_GITHUB_ACTIONS, reason='Currently no data in astroquery.mast.  This can be removed for JWST operations.')
 def test_mast_query_darks():
     """Test that the MAST query for darks is functional"""
 
diff --git a/jwql/tests/test_monitor_mast.py b/jwql/tests/test_monitor_mast.py
--- a/jwql/tests/test_monitor_mast.py
+++ b/jwql/tests/test_monitor_mast.py
@@ -17,10 +17,18 @@
         pytest -s test_monitor_mast.py
 """
 
+import os
+
 from astroquery.mast import Mast
 
 from jwql.jwql_monitors import monitor_mast as mm
 from jwql.utils.constants import JWST_INSTRUMENT_NAMES
+from jwql.utils.utils import get_config
+
+# Temporary until JWST operations: switch to test string for MAST request URL
+ON_GITHUB_ACTIONS = '/home/runner' in os.path.expanduser('~') or '/Users/runner' in os.path.expanduser('~')
+if not ON_GITHUB_ACTIONS:
+    Mast._portal_api_connection.MAST_REQUEST_URL = get_config()['mast_request_url']
 
 
 def test_astroquery_mast():