diff --git a/tests/tests_api.py b/tests/tests_api.py index db21be8..8aaa9ce 100755 --- a/tests/tests_api.py +++ b/tests/tests_api.py @@ -7,6 +7,7 @@ # # ### Run Against DEV Server. # usrpw='' serverurl=http://localhost:8050 python -m unittest tests.tests_api +# usrpw='' serverurl=http://sparcdev2.csdc.noirlab.edu:8050 python -m unittest tests.tests_api # noqa: E501 # showact=1 usrpw='' serverurl=http://localhost:8050 python -m unittest tests.tests_api # noqa: E501 # # python -m unittest -v tests.tests_api # VERBOSE (show what is skipped) @@ -55,6 +56,7 @@ import numpy import logging import sys +import warnings # Local Packages from tests.utils import tic, toc @@ -77,7 +79,7 @@ _STAGE = "https://sparclstage.datalab.noirlab.edu" # noqa: E221 _PROD = "https://astrosparcl.datalab.noirlab.edu" # noqa: E221 -serverurl = os.environ.get("serverurl", _PAT1) +serverurl = os.environ.get("serverurl", _PROD) #!DEV_SERVERS = [_DEV1,] DEV_SERVERS = [] @@ -102,6 +104,7 @@ usrpw = os.environ.get("usrpw") +show_run_context = True @contextmanager def streamhandler_to_console(lggr): @@ -165,14 +168,18 @@ def setUpClass(cls): cls.doc = dict() cls.count = dict() - print( - f"Running Client tests\n" - f' against Server: "{urlparse(serverurl).netloc}"\n' - f" comparing to: {exp.__name__}\n" - f" showact={showact}\n" - f" showcurl={showcurl}\n" - f" client={cls.client}\n" - ) + global show_run_context + + if show_run_context: + print( + f"Running Client Tests\n" + f' against Server: "{urlparse(serverurl).netloc}"\n' + f" comparing to: {exp.__name__}\n" + f" showact={showact}\n" + f" showcurl={showcurl}\n" + f" client={cls.client}\n" + ) + show_run_context = False # Get some id_lists to use in tests found = cls.client.find( @@ -182,8 +189,9 @@ def setUpClass(cls): zip(*[(r["sparcl_id"], r["specid"]) for r in found.records]) ) sparc_ids, spec_ids = list(sparc_tups), list(spec_tups) - print(f"sparc_ids={sparc_ids}") - print(f"spec_ids={spec_ids}") + if showact: + print(f"sparc_ids={sparc_ids}") + print(f"spec_ids={spec_ids}") # Lists of SPECID cls.specid_list0 = spec_ids[:2] @@ -275,7 +283,7 @@ def test_missing_specids_1(self): """Specids (not UUID) missing""" badid = "NOT_SPEC_ID" specids = set([badid] + self.specid_list0[:1]) - missing = set(self.client.missing_specids(specids, verbose=True)) + missing = set(self.client.missing_specids(specids, verbose=False)) if showact: print(f"missing_specids_1: specids={specids}") print(f"missing_specids_1: missing={missing}") @@ -472,13 +480,10 @@ def test_reorder_1a(self): """Reorder retrieved records by sparcl_id.""" name = "reorder_1a" ids = self.uuid_list2 - print(f"ids: {ids}") tic() drs = ["SDSS-DR16", "BOSS-DR16", "DESI-EDR"] res = self.client.retrieve(ids, dataset_list=drs) - res_ids = [r["sparcl_id"] for r in res.records] - print(f"retrieved: {res_ids}") self.timing[name] = toc() res_reorder = res.reorder(ids) actual = [f["sparcl_id"] for f in res_reorder.records] @@ -600,7 +605,7 @@ def test_dls_468(self): uuid_list=idss, include=["ra", "dec"], dataset_list=["SDSS-DR16"], - verbose=True, + verbose=False, ) self.assertEqual(1, re.count) @@ -733,14 +738,18 @@ def setUpClass(cls): url=serverurl, verbose=clverb, show_curl=showcurl ) - print( - f"Running Client tests\n" - f' against Server: "{urlparse(serverurl).netloc}"\n' - f" comparing to: {exp.__name__}\n" - f" {showact=}\n" - f" {showcurl=}\n" - f" {cls.client=}\n" - ) + global show_run_context + + if show_run_context: + print( + f"Running Client Tests\n" + f' against Server: "{urlparse(serverurl).netloc}"\n' + f" comparing to: {exp.__name__}\n" + f" showact={showact}\n" + f" showcurl={showcurl}\n" + f" client={cls.client}\n" + ) + show_run_context = False cls.outflds = ["sparcl_id", "data_release"] cls.inc = ["data_release", "flux"] @@ -969,12 +978,14 @@ def test_auth_retrieve_3(self): # retrieve from authorized datasets (Public, in this case) def test_auth_retrieve_4(self): """Retrieve method with unauthorized user; no datasets specified""" + warnings.filterwarnings("ignore") exp = "exp.auth_retrieve_4" self.auth_retrieve(self.unauth_user, None, exp) # | retrieve | Unauth | Pub | PASS | def test_auth_retrieve_5(self): """Retrieve method with unauthorized user; public datasets specified""" + warnings.filterwarnings("ignore") exp = "exp.auth_retrieve_5" self.auth_retrieve(self.unauth_user, self.Pub, exp) @@ -991,11 +1002,13 @@ def test_auth_retrieve_6(self): # retrieve from authorized datasets (Public, in this case) def test_auth_retrieve_7(self): """Retrieve method with anonymous user; no data sets specified""" + warnings.filterwarnings("ignore") exp = "exp.auth_retrieve_7" self.auth_retrieve(None, None, exp) # | retrieve | Anon | Pub | PASS | def test_auth_retrieve_8(self): """Retrieve method with anonymous user; public data sets specified""" + warnings.filterwarnings("ignore") exp = "exp.auth_retrieve_8" self.auth_retrieve(None, self.Pub, exp)