sparclclient 1.2.2b9__tar.gz → 1.2.2b11__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {sparclclient-1.2.2b9 → sparclclient-1.2.2b11}/PKG-INFO +1 -1
- {sparclclient-1.2.2b9 → sparclclient-1.2.2b11}/sparcl/__init__.py +1 -1
- {sparclclient-1.2.2b9 → sparclclient-1.2.2b11}/sparcl/client.py +3 -3
- sparclclient-1.2.2b11/tests/expected_pat.py +121 -0
- {sparclclient-1.2.2b9 → sparclclient-1.2.2b11}/tests/tests_api.py +71 -71
- sparclclient-1.2.2b9/tests/expected_pat.py +0 -286
- {sparclclient-1.2.2b9 → sparclclient-1.2.2b11}/.github/workflows/django.yml +0 -0
- {sparclclient-1.2.2b9 → sparclclient-1.2.2b11}/.gitignore +0 -0
- {sparclclient-1.2.2b9 → sparclclient-1.2.2b11}/.pre-commit-config.yaml +0 -0
- {sparclclient-1.2.2b9 → sparclclient-1.2.2b11}/.readthedocs.yaml +0 -0
- {sparclclient-1.2.2b9 → sparclclient-1.2.2b11}/LICENSE +0 -0
- {sparclclient-1.2.2b9 → sparclclient-1.2.2b11}/Makefile +0 -0
- {sparclclient-1.2.2b9 → sparclclient-1.2.2b11}/README.md +0 -0
- {sparclclient-1.2.2b9 → sparclclient-1.2.2b11}/make.bat +0 -0
- {sparclclient-1.2.2b9 → sparclclient-1.2.2b11}/pyproject.toml +0 -0
- {sparclclient-1.2.2b9 → sparclclient-1.2.2b11}/requirements-client.txt +0 -0
- {sparclclient-1.2.2b9 → sparclclient-1.2.2b11}/requirements-internal.txt +0 -0
- {sparclclient-1.2.2b9 → sparclclient-1.2.2b11}/requirements.txt +0 -0
- {sparclclient-1.2.2b9 → sparclclient-1.2.2b11}/source/conf.py +0 -0
- {sparclclient-1.2.2b9 → sparclclient-1.2.2b11}/source/index.rst +0 -0
- {sparclclient-1.2.2b9 → sparclclient-1.2.2b11}/source/sparcl.rst +0 -0
- {sparclclient-1.2.2b9 → sparclclient-1.2.2b11}/sparcl/Results.py +0 -0
- {sparclclient-1.2.2b9 → sparclclient-1.2.2b11}/sparcl/benchmarks/__init__.py +0 -0
- {sparclclient-1.2.2b9 → sparclclient-1.2.2b11}/sparcl/benchmarks/benchmarks.py +0 -0
- {sparclclient-1.2.2b9 → sparclclient-1.2.2b11}/sparcl/conf.py +0 -0
- {sparclclient-1.2.2b9 → sparclclient-1.2.2b11}/sparcl/exceptions.py +0 -0
- {sparclclient-1.2.2b9 → sparclclient-1.2.2b11}/sparcl/fields.py +0 -0
- {sparclclient-1.2.2b9 → sparclclient-1.2.2b11}/sparcl/gather_2d.py +0 -0
- {sparclclient-1.2.2b9 → sparclclient-1.2.2b11}/sparcl/notebooks/sparcl-examples.ipynb +0 -0
- {sparclclient-1.2.2b9 → sparclclient-1.2.2b11}/sparcl/resample_spectra.py +0 -0
- {sparclclient-1.2.2b9 → sparclclient-1.2.2b11}/sparcl/sparc.ini +0 -0
- {sparclclient-1.2.2b9 → sparclclient-1.2.2b11}/sparcl/type_conversion.py +0 -0
- {sparclclient-1.2.2b9 → sparclclient-1.2.2b11}/sparcl/unsupported.py +0 -0
- {sparclclient-1.2.2b9 → sparclclient-1.2.2b11}/sparcl/utils.py +0 -0
- {sparclclient-1.2.2b9 → sparclclient-1.2.2b11}/tests/expected_dev1.py +0 -0
- {sparclclient-1.2.2b9 → sparclclient-1.2.2b11}/tests/methods_tests.py +0 -0
- {sparclclient-1.2.2b9 → sparclclient-1.2.2b11}/tests/utils.py +0 -0
- {sparclclient-1.2.2b9 → sparclclient-1.2.2b11}/tox.ini +0 -0
|
@@ -163,7 +163,7 @@ class SparclClient: # was SparclApi()
|
|
|
163
163
|
|
|
164
164
|
"""
|
|
165
165
|
|
|
166
|
-
KNOWN_GOOD_API_VERSION =
|
|
166
|
+
KNOWN_GOOD_API_VERSION = 12.0 # @@@ Change when Server version incremented
|
|
167
167
|
|
|
168
168
|
def __init__(
|
|
169
169
|
self,
|
|
@@ -468,7 +468,7 @@ class SparclClient: # was SparclApi()
|
|
|
468
468
|
Example:
|
|
469
469
|
>>> client = SparclClient()
|
|
470
470
|
>>> client.version
|
|
471
|
-
|
|
471
|
+
12.0
|
|
472
472
|
"""
|
|
473
473
|
|
|
474
474
|
if self.apiversion is None:
|
|
@@ -658,7 +658,7 @@ class SparclClient: # was SparclApi()
|
|
|
658
658
|
are NOT stored in the SPARCL database.
|
|
659
659
|
|
|
660
660
|
Example:
|
|
661
|
-
>>> client = SparclClient(
|
|
661
|
+
>>> client = SparclClient()
|
|
662
662
|
>>> found = client.find(outfields=['specid'], limit=2)
|
|
663
663
|
>>> specids = [f.specid for f in found.records]
|
|
664
664
|
>>> client.missing_specids(specids + ['bad_id'])
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
# For running client against PAT host
|
|
2
|
+
# See also: expected_dev1.py (SP DEV)
|
|
3
|
+
|
|
4
|
+
all_fields = [
|
|
5
|
+
"data_release",
|
|
6
|
+
"datasetgroup",
|
|
7
|
+
"dateobs",
|
|
8
|
+
"dateobs_center",
|
|
9
|
+
"dec",
|
|
10
|
+
"exptime",
|
|
11
|
+
"flux",
|
|
12
|
+
"instrument",
|
|
13
|
+
"ivar",
|
|
14
|
+
"mask",
|
|
15
|
+
"model",
|
|
16
|
+
"ra",
|
|
17
|
+
"redshift",
|
|
18
|
+
"redshift_err",
|
|
19
|
+
"redshift_warning",
|
|
20
|
+
"site",
|
|
21
|
+
"sparcl_id",
|
|
22
|
+
"specid",
|
|
23
|
+
"specprimary",
|
|
24
|
+
"spectype",
|
|
25
|
+
"survey",
|
|
26
|
+
"targetid",
|
|
27
|
+
"telescope",
|
|
28
|
+
"wave_sigma",
|
|
29
|
+
"wavelength",
|
|
30
|
+
"wavemax",
|
|
31
|
+
"wavemin",
|
|
32
|
+
]
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
default_fields = ["dec", "flux", "ra", "sparcl_id", "specid", "wavelength"]
|
|
36
|
+
|
|
37
|
+
retrieve_0 = ["_dr", "flux", "sparcl_id", "specid"]
|
|
38
|
+
|
|
39
|
+
retrieve_0b = ["_dr", "dec", "flux", "ra", "sparcl_id", "specid", "wavelength"]
|
|
40
|
+
|
|
41
|
+
retrieve_5 = 2
|
|
42
|
+
|
|
43
|
+
find_0 = [
|
|
44
|
+
{
|
|
45
|
+
"_dr": "BOSS-DR16",
|
|
46
|
+
"data_release": "BOSS-DR16",
|
|
47
|
+
"specid": -6444532452352045056,
|
|
48
|
+
}
|
|
49
|
+
]
|
|
50
|
+
|
|
51
|
+
find_1 = [
|
|
52
|
+
{
|
|
53
|
+
"_dr": "SDSS-DR16",
|
|
54
|
+
"data_release": "SDSS-DR16",
|
|
55
|
+
"specid": 1506454396622366720,
|
|
56
|
+
}
|
|
57
|
+
]
|
|
58
|
+
|
|
59
|
+
find_2 = 936894 # PAT
|
|
60
|
+
|
|
61
|
+
find_3 = [
|
|
62
|
+
{"_dr": "BOSS-DR16", "data_release": "BOSS-DR16"},
|
|
63
|
+
{"_dr": "DESI-EDR", "data_release": "DESI-EDR"},
|
|
64
|
+
{"_dr": "SDSS-DR16", "data_release": "SDSS-DR16"},
|
|
65
|
+
]
|
|
66
|
+
|
|
67
|
+
find_4 = 36
|
|
68
|
+
|
|
69
|
+
find_5a = [
|
|
70
|
+
{"_dr": "BOSS-DR16", "data_release": "BOSS-DR16", "mjd": 55689},
|
|
71
|
+
{"_dr": "SDSS-DR16", "data_release": "SDSS-DR16", "mjd": 54763},
|
|
72
|
+
]
|
|
73
|
+
|
|
74
|
+
find_5d = []
|
|
75
|
+
|
|
76
|
+
authorized_1 = {
|
|
77
|
+
"Loggedin_As": "test_user_1@noirlab.edu",
|
|
78
|
+
"Authorized_Datasets": {
|
|
79
|
+
"BOSS-DR16",
|
|
80
|
+
"DESI-EDR",
|
|
81
|
+
"SDSS-DR16",
|
|
82
|
+
"SDSS-DR17-test",
|
|
83
|
+
},
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
authorized_2 = {
|
|
87
|
+
"Loggedin_As": "test_user_2@noirlab.edu",
|
|
88
|
+
"Authorized_Datasets": {"BOSS-DR16", "DESI-EDR", "SDSS-DR16"},
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
authorized_3 = {
|
|
92
|
+
"Loggedin_As": "Anonymous",
|
|
93
|
+
"Authorized_Datasets": {"BOSS-DR16", "DESI-EDR", "SDSS-DR16"},
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
# Private and Public
|
|
97
|
+
pub_1 = ["BOSS-DR16"]
|
|
98
|
+
pub_all = ["BOSS-DR16", "DESI-EDR", "SDSS-DR16"]
|
|
99
|
+
priv = ["SDSS-DR17-test"]
|
|
100
|
+
unauth = "test_user_2@noirlab.edu"
|
|
101
|
+
#
|
|
102
|
+
auth_find_1 = auth_find_2 = pub_all + priv
|
|
103
|
+
# OLD as of July 9, 2024
|
|
104
|
+
#auth_find_3 = f"[DSDENIED] {unauth} is declined access to datasets {priv}"
|
|
105
|
+
auth_find_3 = auth_retrieve_3 = (f"[DSDENIED] uname='{unauth}' is declined "
|
|
106
|
+
f"access to datasets={priv}; "
|
|
107
|
+
f"drs_requested={pub_all + priv} "
|
|
108
|
+
f"my_auth={pub_all}")
|
|
109
|
+
auth_find_4 = auth_find_6 = pub_all
|
|
110
|
+
# OLD as of July 9, 2024
|
|
111
|
+
#auth_find_5 = f"[DSDENIED] ANONYMOUS is declined access to datasets {priv}"
|
|
112
|
+
auth_find_5 = auth_retrieve_6 = ("[DSDENIED] uname='ANONYMOUS' is declined "
|
|
113
|
+
f"access to datasets={priv}; "
|
|
114
|
+
f"drs_requested={pub_all + priv} "
|
|
115
|
+
f"my_auth={pub_all}")
|
|
116
|
+
auth_retrieve_1 = auth_retrieve_2 = pub_1 + priv
|
|
117
|
+
# OLD as of July 9, 2024
|
|
118
|
+
#auth_retrieve_3 = f"[DSDENIED] {unauth} is declined access to datasets {priv}"
|
|
119
|
+
auth_retrieve_4 = auth_retrieve_5 = auth_retrieve_7 = auth_retrieve_8 = pub_1
|
|
120
|
+
# OLD as of July 9, 2024
|
|
121
|
+
#auth_retrieve_6 = f"[DSDENIED] ANONYMOUS is declined access to datasets {priv}" # noqa: E501
|
|
@@ -61,8 +61,7 @@ import warnings
|
|
|
61
61
|
|
|
62
62
|
# Local Packages
|
|
63
63
|
from tests.utils import tic, toc
|
|
64
|
-
import tests.expected_pat as
|
|
65
|
-
import tests.expected_dev1 as exp_dev
|
|
64
|
+
import tests.expected_pat as exp
|
|
66
65
|
import sparcl.exceptions as ex
|
|
67
66
|
import sparcl.gather_2d as sg
|
|
68
67
|
import sparcl.client
|
|
@@ -81,31 +80,20 @@ _STAGE = "https://sparclstage.datalab.noirlab.edu" # noqa: E221
|
|
|
81
80
|
_PROD = "https://astrosparcl.datalab.noirlab.edu" # noqa: E221
|
|
82
81
|
|
|
83
82
|
serverurl = os.environ.get("serverurl", _PROD)
|
|
84
|
-
#!DEV_SERVERS = [_DEV1,]
|
|
85
|
-
DEV_SERVERS = []
|
|
86
|
-
|
|
87
|
-
if serverurl in DEV_SERVERS:
|
|
88
|
-
exp = exp_dev
|
|
89
|
-
else:
|
|
90
|
-
exp = exp_pat
|
|
91
|
-
|
|
92
83
|
showact = False
|
|
93
84
|
showact = showact or os.environ.get("showact") == "1"
|
|
94
|
-
|
|
95
85
|
showcurl = False
|
|
96
86
|
showcurl = showcurl or os.environ.get("showcurl") == "1"
|
|
97
|
-
|
|
98
87
|
clverb = False
|
|
99
88
|
clverb = clverb or os.environ.get("clverb") == "1"
|
|
100
|
-
|
|
101
89
|
showall = False
|
|
102
90
|
showall = showall or os.environ.get("showall") == "1"
|
|
103
91
|
if showall:
|
|
104
92
|
showact = showcurl = clverb = True
|
|
105
93
|
|
|
106
|
-
usrpw = os.environ.get("usrpw")
|
|
94
|
+
usrpw = os.environ.get("usrpw") # password for test users
|
|
95
|
+
show_run_context = True # Print message about parameters of this test run
|
|
107
96
|
|
|
108
|
-
show_run_context = True
|
|
109
97
|
|
|
110
98
|
@contextmanager
|
|
111
99
|
def streamhandler_to_console(lggr):
|
|
@@ -134,14 +122,37 @@ def testcase_log_console(lggr):
|
|
|
134
122
|
def load_tests(loader, tests, ignore):
|
|
135
123
|
import doctest
|
|
136
124
|
|
|
137
|
-
|
|
138
|
-
|
|
125
|
+
if serverurl == _PROD:
|
|
126
|
+
print(f"Arranging to run doctests against: sparcl.client")
|
|
127
|
+
tests.addTests(doctest.DocTestSuite(sparcl.client))
|
|
128
|
+
|
|
129
|
+
print(f"Arranging to run doctests against: sparcl.gather_2d")
|
|
130
|
+
tests.addTests(doctest.DocTestSuite(sparcl.gather_2d))
|
|
131
|
+
else:
|
|
132
|
+
print(
|
|
133
|
+
"Not running doctests since you are not running client"
|
|
134
|
+
" against the PRODUCTION server."
|
|
135
|
+
)
|
|
139
136
|
|
|
140
|
-
print(f"Arranging to run doctests against: sparcl.gather_2d")
|
|
141
|
-
tests.addTests(doctest.DocTestSuite(sparcl.gather_2d))
|
|
142
137
|
return tests
|
|
143
138
|
|
|
144
139
|
|
|
140
|
+
def print_run_context(cls):
|
|
141
|
+
print(
|
|
142
|
+
f"""
|
|
143
|
+
Running Client Tests
|
|
144
|
+
against Server: \t"{urlparse(serverurl).netloc}"
|
|
145
|
+
comparing to: \t{exp.__name__}
|
|
146
|
+
{showact=}
|
|
147
|
+
{showcurl=}
|
|
148
|
+
client={cls.client}
|
|
149
|
+
|
|
150
|
+
For REPRODUCIBLE RESULTS rebuild Server DB before running tests!
|
|
151
|
+
Use: init-db.sh
|
|
152
|
+
"""
|
|
153
|
+
)
|
|
154
|
+
|
|
155
|
+
|
|
145
156
|
class SparclClientTest(unittest.TestCase):
|
|
146
157
|
"""Test access to each endpoint of the Server API"""
|
|
147
158
|
|
|
@@ -172,14 +183,7 @@ class SparclClientTest(unittest.TestCase):
|
|
|
172
183
|
global show_run_context
|
|
173
184
|
|
|
174
185
|
if show_run_context:
|
|
175
|
-
|
|
176
|
-
f"Running Client Tests\n"
|
|
177
|
-
f' against Server: "{urlparse(serverurl).netloc}"\n'
|
|
178
|
-
f" comparing to: {exp.__name__}\n"
|
|
179
|
-
f" showact={showact}\n"
|
|
180
|
-
f" showcurl={showcurl}\n"
|
|
181
|
-
f" client={cls.client}\n"
|
|
182
|
-
)
|
|
186
|
+
print_run_context(cls)
|
|
183
187
|
show_run_context = False
|
|
184
188
|
|
|
185
189
|
# Get some id_lists to use in tests
|
|
@@ -354,8 +358,10 @@ class SparclClientTest(unittest.TestCase):
|
|
|
354
358
|
"""Limit number of records returned by retrieve_by_specid."""
|
|
355
359
|
drs = ["SDSS-DR16", "BOSS-DR16", "DESI-EDR"]
|
|
356
360
|
res = self.client.retrieve_by_specid(
|
|
357
|
-
self.specid_list5,
|
|
358
|
-
|
|
361
|
+
self.specid_list5,
|
|
362
|
+
include=["specid", "ivar"],
|
|
363
|
+
dataset_list=drs,
|
|
364
|
+
limit=2,
|
|
359
365
|
)
|
|
360
366
|
actual = len(res.records)
|
|
361
367
|
if showact:
|
|
@@ -367,31 +373,27 @@ class SparclClientTest(unittest.TestCase):
|
|
|
367
373
|
"""Get metadata using search spec."""
|
|
368
374
|
|
|
369
375
|
outfields = ["data_release", "specid"]
|
|
370
|
-
# from list(FitsRecord.objects.all().values('ra','dec'))
|
|
371
|
-
|
|
372
376
|
# To get suitable constraints (in sparc-shell on Server):
|
|
373
|
-
#
|
|
374
|
-
|
|
375
|
-
#if serverurl in DEV_SERVERS:
|
|
376
|
-
# !constraints = {"ra": [246.0, 247.0], "dec": [+34.7, +34.8]}
|
|
377
|
-
# constraints = {"ra": [194.0, 195.0], "dec": [+27.5, +27.6]}
|
|
378
|
-
#else:
|
|
379
|
-
# constraints = {"ra": [340.0, 341.0], "dec": [+3.0, +4.0]}
|
|
380
|
-
constraints = {"ra": [134.288, 134.291], "dec": [+28.34, +28.351]}
|
|
377
|
+
# list(FitsRecord.objects.all().values('ra','dec'))
|
|
378
|
+
constraints = {"ra": [132.1, 132.2], "dec": [+28.0, +28.1]}
|
|
381
379
|
found = self.client.find(outfields, constraints=constraints, limit=3)
|
|
382
380
|
actual = found.records[:2]
|
|
383
381
|
if showact:
|
|
384
382
|
print(f"find_0: actual={pf(actual[:2])}")
|
|
385
383
|
self.assertEqual(actual, exp.find_0, msg="Actual to Expected")
|
|
386
384
|
|
|
385
|
+
@skip("fiddly bit skipped until we use factoryboy")
|
|
387
386
|
def test_find_1(self):
|
|
388
387
|
"""Get metadata using search spec."""
|
|
389
388
|
outfields = ["data_release", "specid"]
|
|
390
|
-
constraints =
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
389
|
+
constraints = {
|
|
390
|
+
"redshift": [0.191, 0.192],
|
|
391
|
+
"exptime": [2100.2, 2100.31],
|
|
392
|
+
"data_release": ["SDSS-DR16"],
|
|
393
|
+
}
|
|
394
|
+
found = self.client.find(
|
|
395
|
+
outfields, constraints=constraints, limit=1, sort="specid"
|
|
396
|
+
) # @@@
|
|
395
397
|
actual = sorted(found.records, key=lambda rec: rec["specid"])
|
|
396
398
|
if showact:
|
|
397
399
|
print(f"find_1: actual={pf(actual)}")
|
|
@@ -523,7 +525,7 @@ class SparclClientTest(unittest.TestCase):
|
|
|
523
525
|
actual = [f["sparcl_id"] for f in res_reorder.records]
|
|
524
526
|
if showact:
|
|
525
527
|
print(f"reorder_2a: actual={pf(actual)}")
|
|
526
|
-
self.assertEqual(actual, ids[:2] + [
|
|
528
|
+
self.assertEqual(actual, ids[:2] + ["None"], msg="Actual to Expected")
|
|
527
529
|
|
|
528
530
|
def test_reorder_2b(self):
|
|
529
531
|
"""Reorder records when specid is missing from database, after
|
|
@@ -540,8 +542,9 @@ class SparclClientTest(unittest.TestCase):
|
|
|
540
542
|
actual = [f["specid"] for f in res_reorder.records]
|
|
541
543
|
if showact:
|
|
542
544
|
print(f"reorder_2b: actual={pf(actual)}")
|
|
543
|
-
self.assertEqual(
|
|
544
|
-
|
|
545
|
+
self.assertEqual(
|
|
546
|
+
actual, specids[:2] + [None], msg="Actual to Expected"
|
|
547
|
+
)
|
|
545
548
|
|
|
546
549
|
def test_reorder_3a(self):
|
|
547
550
|
"""Test for expected Exception when a list of sparcl_ids with
|
|
@@ -742,14 +745,7 @@ class AuthTest(unittest.TestCase):
|
|
|
742
745
|
global show_run_context
|
|
743
746
|
|
|
744
747
|
if show_run_context:
|
|
745
|
-
|
|
746
|
-
f"Running Client Tests\n"
|
|
747
|
-
f' against Server: "{urlparse(serverurl).netloc}"\n'
|
|
748
|
-
f" comparing to: {exp.__name__}\n"
|
|
749
|
-
f" showact={showact}\n"
|
|
750
|
-
f" showcurl={showcurl}\n"
|
|
751
|
-
f" client={cls.client}\n"
|
|
752
|
-
)
|
|
748
|
+
print_run_context(cls)
|
|
753
749
|
show_run_context = False
|
|
754
750
|
|
|
755
751
|
cls.outflds = ["sparcl_id", "data_release"]
|
|
@@ -781,18 +777,18 @@ class AuthTest(unittest.TestCase):
|
|
|
781
777
|
sort="sparcl_id",
|
|
782
778
|
)
|
|
783
779
|
).ids
|
|
784
|
-
#cls.uuid_pub = ( # cls.uuid_sdssdr16
|
|
780
|
+
# cls.uuid_pub = ( # cls.uuid_sdssdr16
|
|
785
781
|
# cls.client.find(
|
|
786
782
|
# outfields=out,
|
|
787
783
|
# constraints={"data_release": cls.Pub},
|
|
788
784
|
# limit=2,
|
|
789
785
|
# sort="sparcl_id",
|
|
790
786
|
# )
|
|
791
|
-
#).ids
|
|
787
|
+
# ).ids
|
|
792
788
|
cls.uuid_pub = (
|
|
793
789
|
cls.client.find(
|
|
794
790
|
outfields=out,
|
|
795
|
-
constraints={"data_release": [
|
|
791
|
+
constraints={"data_release": ["BOSS-DR16"]},
|
|
796
792
|
limit=2,
|
|
797
793
|
sort="sparcl_id",
|
|
798
794
|
)
|
|
@@ -823,7 +819,6 @@ class AuthTest(unittest.TestCase):
|
|
|
823
819
|
def tearDownClass(cls):
|
|
824
820
|
pass
|
|
825
821
|
|
|
826
|
-
|
|
827
822
|
# curl -X 'POST' \
|
|
828
823
|
# 'http://localhost:8050/sparc/get_token/' \
|
|
829
824
|
# -H 'Content-Type: application/json' \
|
|
@@ -832,23 +827,30 @@ class AuthTest(unittest.TestCase):
|
|
|
832
827
|
# > Could not get token from SSO server:
|
|
833
828
|
# HTTPSConnectionPool(host='docker1.csdc.noirlab.edu', port=443):
|
|
834
829
|
# Max retries exceeded with url: /api/token/
|
|
835
|
-
# (Caused by SSLError(SSLCertVerificationError(1,
|
|
830
|
+
# (Caused by SSLError(SSLCertVerificationError(1,
|
|
831
|
+
# '[SSL: CERTIFICATE_VERIFY_FAILED]
|
|
836
832
|
# certificate verify failed: unable to get local issuer certificate
|
|
837
833
|
# (_ssl.c:997)')))
|
|
834
|
+
|
|
835
|
+
def test_sso_server(self):
|
|
836
|
+
sso_server = "https://sso.csdc.noirlab.edu/"
|
|
837
|
+
response = requests.get(sso_server)
|
|
838
|
+
self.assertEqual(response.status_code, 200, response.content.decode())
|
|
839
|
+
|
|
838
840
|
def test_get_token(self):
|
|
839
|
-
|
|
841
|
+
"""Make sure we can get expected SSO token."""
|
|
840
842
|
json = {"email": self.auth_user, "password": usrpw}
|
|
841
843
|
if showact:
|
|
842
|
-
print(f
|
|
844
|
+
print(f"test_get_token: {json=}")
|
|
843
845
|
|
|
844
|
-
expected =
|
|
845
|
-
res = requests.post(f
|
|
846
|
+
expected = 281
|
|
847
|
+
res = requests.post(f"{self.client.apiurl}/get_token/", json=json)
|
|
846
848
|
self.assertEqual(res.status_code, 200, res.content.decode())
|
|
847
|
-
|
|
849
|
+
token = res.content.decode()
|
|
850
|
+
actual = len(token)
|
|
848
851
|
if showact:
|
|
849
|
-
print(f
|
|
850
|
-
self.assertEqual(
|
|
851
|
-
|
|
852
|
+
print(f"test_get_token: ({len(token)}) {token=!s}")
|
|
853
|
+
self.assertEqual(actual, expected, msg="Actual to Expected")
|
|
852
854
|
|
|
853
855
|
def test_authorized_1(self):
|
|
854
856
|
"""Test authorized method with authorized user signed in"""
|
|
@@ -919,9 +921,7 @@ class AuthTest(unittest.TestCase):
|
|
|
919
921
|
inc = ["sparcl_id", "data_release"]
|
|
920
922
|
try:
|
|
921
923
|
if drs is None:
|
|
922
|
-
got = self.client.retrieve(
|
|
923
|
-
uuid_list=ids, include=inc
|
|
924
|
-
)
|
|
924
|
+
got = self.client.retrieve(uuid_list=ids, include=inc)
|
|
925
925
|
else:
|
|
926
926
|
got = self.client.retrieve(
|
|
927
927
|
uuid_list=ids, include=inc, dataset_list=drs
|
|
@@ -1,286 +0,0 @@
|
|
|
1
|
-
# For running client against PAT host
|
|
2
|
-
# See also: expected_dev1.py (SP DEV)
|
|
3
|
-
|
|
4
|
-
all_fields = [
|
|
5
|
-
"data_release",
|
|
6
|
-
"datasetgroup",
|
|
7
|
-
"dateobs",
|
|
8
|
-
"dateobs_center",
|
|
9
|
-
"dec",
|
|
10
|
-
"exptime",
|
|
11
|
-
"flux",
|
|
12
|
-
"instrument",
|
|
13
|
-
"ivar",
|
|
14
|
-
"mask",
|
|
15
|
-
"model",
|
|
16
|
-
"ra",
|
|
17
|
-
"redshift",
|
|
18
|
-
"redshift_err",
|
|
19
|
-
"redshift_warning",
|
|
20
|
-
"site",
|
|
21
|
-
"sparcl_id",
|
|
22
|
-
"specid",
|
|
23
|
-
"specprimary",
|
|
24
|
-
"spectype",
|
|
25
|
-
"survey",
|
|
26
|
-
"targetid",
|
|
27
|
-
"telescope",
|
|
28
|
-
"wave_sigma",
|
|
29
|
-
"wavelength",
|
|
30
|
-
"wavemax",
|
|
31
|
-
"wavemin",
|
|
32
|
-
]
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
default_fields = ["dec", "flux", "ra", "sparcl_id", "specid", "wavelength"]
|
|
36
|
-
|
|
37
|
-
# OLD as of Dec 14, 2023
|
|
38
|
-
# retrieve_0 = [1254334738051655680, 1254335012929562624]
|
|
39
|
-
|
|
40
|
-
# OLD as of May 3, 2024
|
|
41
|
-
#retrieve_0 = [39627920993422590, 39627926995470031]
|
|
42
|
-
|
|
43
|
-
retrieve_0 = ["_dr", "flux", "sparcl_id", "specid"]
|
|
44
|
-
|
|
45
|
-
retrieve_0b = ["_dr", "dec", "flux", "ra", "sparcl_id", "specid", "wavelength"]
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
# OLD as of Dec 14, 2023
|
|
49
|
-
# retrieve_5 = [1254334738051655680, 1254335012929562624]
|
|
50
|
-
|
|
51
|
-
# OLD as of May 3, 2024
|
|
52
|
-
#retrieve_5 = [39627920993422590, 39627926995470031]
|
|
53
|
-
|
|
54
|
-
retrieve_5 = 2
|
|
55
|
-
|
|
56
|
-
# OLD as of Dec 14, 2023
|
|
57
|
-
# find_0 = [
|
|
58
|
-
# {
|
|
59
|
-
# "_dr": "BOSS-DR16",
|
|
60
|
-
# "dec": 28.038113,
|
|
61
|
-
# "ra": 132.95902999999998,
|
|
62
|
-
# "sparcl_id": "611a5a1c-75d8-11ee-8b9f-525400aad0aa",
|
|
63
|
-
# },
|
|
64
|
-
# {
|
|
65
|
-
# "_dr": "BOSS-DR16",
|
|
66
|
-
# "dec": 28.019856,
|
|
67
|
-
# "ra": 132.93685,
|
|
68
|
-
# "sparcl_id": "61357ba4-75d8-11ee-a1b5-525400aad0aa",
|
|
69
|
-
# },
|
|
70
|
-
# ]
|
|
71
|
-
|
|
72
|
-
# OLD as of May 3, 2024
|
|
73
|
-
#find_0 = [
|
|
74
|
-
# {
|
|
75
|
-
# "_dr": "BOSS-DR16",
|
|
76
|
-
# "dec": 3.4911852,
|
|
77
|
-
# "ra": 340.93613000000005,
|
|
78
|
-
# "sparcl_id": "0c46e982-992d-11ee-b800-525400aad0aa",
|
|
79
|
-
# },
|
|
80
|
-
# {
|
|
81
|
-
# "_dr": "BOSS-DR16",
|
|
82
|
-
# "dec": 3.0464991,
|
|
83
|
-
# "ra": 340.93298000000004,
|
|
84
|
-
# "sparcl_id": "2602c4a5-992d-11ee-b3e7-525400aad0aa",
|
|
85
|
-
# },
|
|
86
|
-
#]
|
|
87
|
-
|
|
88
|
-
find_0 = [{'_dr': 'BOSS-DR16',
|
|
89
|
-
'data_release': 'BOSS-DR16',
|
|
90
|
-
'specid': -6444642403514822656}]
|
|
91
|
-
|
|
92
|
-
# OLD as of Dec 14, 2023
|
|
93
|
-
# find_1 = [
|
|
94
|
-
# {
|
|
95
|
-
# "_dr": "SDSS-DR17",
|
|
96
|
-
# "dec": -0.98681,
|
|
97
|
-
# "ra": 313.90848,
|
|
98
|
-
# "sparcl_id": "0002f55c-75d7-11ee-822f-525400aad0aa",
|
|
99
|
-
# }
|
|
100
|
-
# ]
|
|
101
|
-
|
|
102
|
-
# OLD as of May 3, 2024
|
|
103
|
-
#find_1 = [
|
|
104
|
-
# {
|
|
105
|
-
# "_dr": "DESI-EDR",
|
|
106
|
-
# "dec": 5.662937176455572,
|
|
107
|
-
# "ra": 208.7076645721256,
|
|
108
|
-
# "sparcl_id": "00063e73-992e-11ee-ad57-525400aad0aa",
|
|
109
|
-
# }
|
|
110
|
-
#]
|
|
111
|
-
|
|
112
|
-
find_1 = [{'_dr': 'SDSS-DR16',
|
|
113
|
-
'data_release': 'SDSS-DR16',
|
|
114
|
-
'specid': 1506454396622366720}]
|
|
115
|
-
|
|
116
|
-
find_2 = 936894 # PAT
|
|
117
|
-
|
|
118
|
-
# OLD as of Dec 14, 2023
|
|
119
|
-
# find_3 = [
|
|
120
|
-
# {
|
|
121
|
-
# "_dr": "SDSS-DR17",
|
|
122
|
-
# "dec": -0.98681,
|
|
123
|
-
# "ra": 313.90848,
|
|
124
|
-
# "sparcl_id": "0002f55c-75d7-11ee-822f-525400aad0aa",
|
|
125
|
-
# },
|
|
126
|
-
# {
|
|
127
|
-
# "_dr": "SDSS-DR17",
|
|
128
|
-
# "dec": -0.945676,
|
|
129
|
-
# "ra": 313.91043,
|
|
130
|
-
# "sparcl_id": "000df610-75d7-11ee-9957-525400aad0aa",
|
|
131
|
-
# },
|
|
132
|
-
# {
|
|
133
|
-
# "_dr": "SDSS-DR17",
|
|
134
|
-
# "dec": -0.486388,
|
|
135
|
-
# "ra": 313.70407,
|
|
136
|
-
# "sparcl_id": "0018f253-75d7-11ee-8253-525400aad0aa",
|
|
137
|
-
# },
|
|
138
|
-
# ]
|
|
139
|
-
|
|
140
|
-
# OLD as of March 13, 2024
|
|
141
|
-
# find_3 = [{'_dr': 'DESI-EDR',
|
|
142
|
-
# 'dec': 5.662937176455572,
|
|
143
|
-
# 'ra': 208.7076645721256,
|
|
144
|
-
# 'sparcl_id': '00063e73-992e-11ee-ad57-525400aad0aa'},
|
|
145
|
-
# {'_dr': 'DESI-EDR',
|
|
146
|
-
# 'dec': 5.492057016906403,
|
|
147
|
-
# 'ra': 209.52823969727436,
|
|
148
|
-
# 'sparcl_id': '000d4892-9931-11ee-9e4d-525400aad0aa'},
|
|
149
|
-
# {'_dr': 'SDSS-DR17',
|
|
150
|
-
# 'dec': 34.863511,
|
|
151
|
-
# 'ra': 194.86904,
|
|
152
|
-
# 'sparcl_id': '000e388f-992d-11ee-a373-525400aad0aa'}]
|
|
153
|
-
|
|
154
|
-
# OLD as of May 3, 2024
|
|
155
|
-
#find_3 = [
|
|
156
|
-
# {
|
|
157
|
-
# "_dr": "DESI-EDR",
|
|
158
|
-
# "dec": 5.662937176455572,
|
|
159
|
-
# "ra": 208.7076645721256,
|
|
160
|
-
# "sparcl_id": "00063e73-992e-11ee-ad57-525400aad0aa",
|
|
161
|
-
# },
|
|
162
|
-
# {
|
|
163
|
-
# "_dr": "DESI-EDR",
|
|
164
|
-
# "dec": 5.492057016906403,
|
|
165
|
-
# "ra": 209.52823969727436,
|
|
166
|
-
# "sparcl_id": "000d4892-9931-11ee-9e4d-525400aad0aa",
|
|
167
|
-
# },
|
|
168
|
-
# {
|
|
169
|
-
# "_dr": "BOSS-DR16",
|
|
170
|
-
# "dec": 27.461703,
|
|
171
|
-
# "ra": 141.95067,
|
|
172
|
-
# "sparcl_id": "001b11a6-992f-11ee-993c-525400aad0aa",
|
|
173
|
-
# },
|
|
174
|
-
#]
|
|
175
|
-
|
|
176
|
-
find_3 = [{'_dr': 'BOSS-DR16', 'data_release': 'BOSS-DR16'},
|
|
177
|
-
{'_dr': 'BOSS-DR16', 'data_release': 'BOSS-DR16'},
|
|
178
|
-
{'_dr': 'BOSS-DR16', 'data_release': 'BOSS-DR16'}]
|
|
179
|
-
|
|
180
|
-
# OLD as of Dec 14, 2023
|
|
181
|
-
# find_4 = [
|
|
182
|
-
# "0002f55c-75d7-11ee-822f-525400aad0aa",
|
|
183
|
-
# "000df610-75d7-11ee-9957-525400aad0aa",
|
|
184
|
-
# "0018f253-75d7-11ee-8253-525400aad0aa",
|
|
185
|
-
# ]
|
|
186
|
-
|
|
187
|
-
# OLD as of March 13, 2024
|
|
188
|
-
# find_4 = ['00063e73-992e-11ee-ad57-525400aad0aa',
|
|
189
|
-
# '000d4892-9931-11ee-9e4d-525400aad0aa',
|
|
190
|
-
# '000e388f-992d-11ee-a373-525400aad0aa']
|
|
191
|
-
|
|
192
|
-
# OLD as of May 3, 2024
|
|
193
|
-
#find_4 = [
|
|
194
|
-
# "00063e73-992e-11ee-ad57-525400aad0aa",
|
|
195
|
-
# "000d4892-9931-11ee-9e4d-525400aad0aa",
|
|
196
|
-
# "001b11a6-992f-11ee-993c-525400aad0aa",
|
|
197
|
-
#]
|
|
198
|
-
|
|
199
|
-
find_4 = 36
|
|
200
|
-
|
|
201
|
-
find_5a = [
|
|
202
|
-
{"_dr": "BOSS-DR16", "data_release": "BOSS-DR16", "mjd": 55689},
|
|
203
|
-
{"_dr": "SDSS-DR16", "data_release": "SDSS-DR16", "mjd": 54763},
|
|
204
|
-
]
|
|
205
|
-
|
|
206
|
-
find_5d = []
|
|
207
|
-
|
|
208
|
-
# OLD as of Dec 14, 2023
|
|
209
|
-
# reorder_1a = [
|
|
210
|
-
# "9452379f-d82d-43bb-8fc2-c26451df4710",
|
|
211
|
-
# "529936c6-14ef-4119-a80d-b184dcb6308e",
|
|
212
|
-
# "fbb22144-25c5-4330-9b0b-8b2eac83079c",
|
|
213
|
-
# ]
|
|
214
|
-
|
|
215
|
-
# OLD as of March 13, 2024
|
|
216
|
-
# reorder_1a = ['00063e73-992e-11ee-ad57-525400aad0aa',
|
|
217
|
-
# '000d4892-9931-11ee-9e4d-525400aad0aa',
|
|
218
|
-
# '000e388f-992d-11ee-a373-525400aad0aa']
|
|
219
|
-
|
|
220
|
-
# OLD as of May 3, 2024
|
|
221
|
-
#reorder_1a = [
|
|
222
|
-
# "00063e73-992e-11ee-ad57-525400aad0aa",
|
|
223
|
-
# "000d4892-9931-11ee-9e4d-525400aad0aa",
|
|
224
|
-
# "001b11a6-992f-11ee-993c-525400aad0aa",
|
|
225
|
-
#]
|
|
226
|
-
|
|
227
|
-
# OLD as of Dec 14, 2023
|
|
228
|
-
# reorder_1b = [1254334738051655680, 1254335012929562624, 1254335287807469568]
|
|
229
|
-
|
|
230
|
-
# OLD as of March 13, 2024
|
|
231
|
-
# reorder_1b = [39627926995470031, 39627920993422590, 2258670445286942720]
|
|
232
|
-
|
|
233
|
-
# OLD as of May 3, 2024
|
|
234
|
-
#reorder_1b = [39627926995470031, 39627920993422590, -5672180510041550848]
|
|
235
|
-
|
|
236
|
-
# OLD as of Dec 14, 2023
|
|
237
|
-
# reorder_2a = [1254334738051655680, 1254335012929562624, None]
|
|
238
|
-
|
|
239
|
-
# OLD as of May 3, 2024
|
|
240
|
-
#reorder_2a = [
|
|
241
|
-
# "00063e73-992e-11ee-ad57-525400aad0aa",
|
|
242
|
-
# "000d4892-9931-11ee-9e4d-525400aad0aa",
|
|
243
|
-
# "None",
|
|
244
|
-
#]
|
|
245
|
-
|
|
246
|
-
# OLD as of Dec 14, 2023
|
|
247
|
-
# reorder_2b = [1254334738051655680, 1254335012929562624, None]
|
|
248
|
-
|
|
249
|
-
# OLD as of May 3, 2024
|
|
250
|
-
#reorder_2b = [39627926995470031, 39627920993422590, None]
|
|
251
|
-
|
|
252
|
-
authorized_1 = {
|
|
253
|
-
"Loggedin_As": "test_user_1@noirlab.edu",
|
|
254
|
-
"Authorized_Datasets": {
|
|
255
|
-
"BOSS-DR16",
|
|
256
|
-
"DESI-EDR",
|
|
257
|
-
"SDSS-DR16",
|
|
258
|
-
"SDSS-DR17-test",
|
|
259
|
-
},
|
|
260
|
-
}
|
|
261
|
-
|
|
262
|
-
authorized_2 = {
|
|
263
|
-
"Loggedin_As": "test_user_2@noirlab.edu",
|
|
264
|
-
"Authorized_Datasets": {"BOSS-DR16", "DESI-EDR", "SDSS-DR16"},
|
|
265
|
-
}
|
|
266
|
-
|
|
267
|
-
authorized_3 = {
|
|
268
|
-
"Loggedin_As": "Anonymous",
|
|
269
|
-
"Authorized_Datasets": {"BOSS-DR16", "DESI-EDR", "SDSS-DR16"},
|
|
270
|
-
}
|
|
271
|
-
|
|
272
|
-
# Private and Public
|
|
273
|
-
pub_1 = ["BOSS-DR16"]
|
|
274
|
-
pub_all = ["BOSS-DR16", "DESI-EDR", "SDSS-DR16"]
|
|
275
|
-
priv = ["SDSS-DR17-test"]
|
|
276
|
-
unauth = "test_user_2@noirlab.edu"
|
|
277
|
-
#
|
|
278
|
-
auth_find_1 = auth_find_2 = pub_all + priv
|
|
279
|
-
auth_find_3 = f"[DSDENIED] {unauth} is declined access to datasets {priv}"
|
|
280
|
-
auth_find_4 = auth_find_6 = pub_all
|
|
281
|
-
auth_find_5 = f"[DSDENIED] ANONYMOUS is declined access to datasets {priv}"
|
|
282
|
-
#
|
|
283
|
-
auth_retrieve_1 = auth_retrieve_2 = pub_1 + priv
|
|
284
|
-
auth_retrieve_3 = f"[DSDENIED] {unauth} is declined access to datasets {priv}"
|
|
285
|
-
auth_retrieve_4 = auth_retrieve_5 = auth_retrieve_7 = auth_retrieve_8 = pub_1
|
|
286
|
-
auth_retrieve_6 = f"[DSDENIED] ANONYMOUS is declined access to datasets {priv}"
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|