Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement test suggestions, update expected values #35

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 20 additions & 8 deletions tests/expected_pat.py
Original file line number Diff line number Diff line change
Expand Up @@ -278,17 +278,29 @@
]

auth_retrieve_1 = (
"SDSS-DR16, 3848 ; SDSS-DR16, 3848 ; "
"SDSS-DR17-test, 3859 ; SDSS-DR17-test, 3859 ; "
['SDSS-DR16, 3848 ; ', 'SDSS-DR16, 3848 ; ',
'SDSS-DR17-test, 3859 ; ', 'SDSS-DR17-test, 3859 ; ']
)

auth_retrieve_2 = (
"DESI-EDR, 7781 ; BOSS-DR16, 4615 ; "
"BOSS-DR16, 4615 ; SDSS-DR16, 3848 ; "
"SDSS-DR16, 3848 ; DESI-EDR, 7781 ; "
"SDSS-DR17-test, 3859 ; SDSS-DR17-test, 3859 ; "
['DESI-EDR, 7781 ; ', 'BOSS-DR16, 4615 ; ',
'BOSS-DR16, 4615 ; ', 'SDSS-DR16, 3848 ; ',
'SDSS-DR16, 3848 ; ', 'DESI-EDR, 7781 ; ',
'SDSS-DR17-test, 3859 ; ', 'SDSS-DR17-test, 3859 ; ']
)

auth_retrieve_5 = "SDSS-DR16, 3848 ; SDSS-DR16, 3848 ; "
auth_retrieve_4 = (
['DESI-EDR, 7781 ; ', 'BOSS-DR16, 4615 ; ',
'BOSS-DR16, 4615 ; ', 'SDSS-DR16, 3848 ; ',
'SDSS-DR16, 3848 ; ', 'DESI-EDR, 7781 ; ']
)

auth_retrieve_5 = ['SDSS-DR16, 3848 ; ', 'SDSS-DR16, 3848 ; ']

auth_retrieve_7 = (
['DESI-EDR, 7781 ; ', 'BOSS-DR16, 4615 ; ',
'BOSS-DR16, 4615 ; ', 'SDSS-DR16, 3848 ; ',
'SDSS-DR16, 3848 ; ', 'DESI-EDR, 7781 ; ']
)

auth_retrieve_8 = "SDSS-DR16, 3848 ; SDSS-DR16, 3848 ; "
auth_retrieve_8 = ['SDSS-DR16, 3848 ; ', 'SDSS-DR16, 3848 ; ']
67 changes: 13 additions & 54 deletions tests/tests_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -855,7 +855,6 @@ def test_auth_find_1(self):
if showact:
print(f"{found.records=}")

#!actual = sorted(found.ids)
actual = sorted(
[(r.sparcl_id, r._dr) for r in found.records], key=lambda r: r[0]
)
Expand Down Expand Up @@ -892,7 +891,7 @@ def test_auth_find_3(self):
cons = dict(data_release=self.PrivPub)
cons.update(self.cons)

# Replace exception name below once real one is created
# @@@ Replace exception name below once real one is created
with self.assertRaises(ex.UnknownServerError):
self.client.find(
outfields=self.outflds,
Expand Down Expand Up @@ -928,7 +927,7 @@ def test_auth_find_5(self):
cons = dict(data_release=self.PrivPub)
cons.update(self.cons)

# Replace exception name below once real one is created
# @@@ Replace exception name below once real one is created
with self.assertRaises(ex.UnknownServerError):
self.client.find(
outfields=self.outflds,
Expand Down Expand Up @@ -958,15 +957,11 @@ def test_auth_find_6(self):
def test_auth_retrieve_1(self):
"""Retrieve method with authorized user; private data set specified"""
self.silent_login(self.auth_user, usrpw)
#!inc = ["data_release", "flux"]
#!uuids = self.uuid_priv + self.uuid_sdssdr16
uuids = self.uuid_priv + self.uuid_pub
got = self.client.retrieve(
uuid_list=uuids, include=self.inc, dataset_list=self.PrivPub
)
actual = ""
for rec in got.records:
actual += rec.data_release + ", " + str(len(rec.flux)) + " ; "
actual = [f'{r.data_release}, {len(r.flux)} ; ' for r in got.records]
if showact:
print(f"auth_retrieve_1: actual={pf(actual)}")
self.assertEqual(actual, exp.auth_retrieve_1, msg="Actual to Expected")
Expand All @@ -976,10 +971,10 @@ def test_auth_retrieve_1(self):
def test_auth_retrieve_2(self):
"""Retrieve method with authorized user; no data sets specified"""
self.silent_login(self.auth_user, usrpw)
print(f"uuids: {self.uuid_all}")
print(f"include: {self.inc}")
got = self.client.retrieve(uuid_list=self.uuid_all, include=self.inc)
actual = ""
for rec in got.records:
actual += rec.data_release + ", " + str(len(rec.flux)) + " ; "
actual = [f'{r.data_release}, {len(r.flux)} ; ' for r in got.records]
if showact:
print(f"auth_retrieve_2: actual={pf(actual)}")
self.assertEqual(actual, exp.auth_retrieve_2, msg="Actual to Expected")
Expand All @@ -989,10 +984,7 @@ def test_auth_retrieve_2(self):
def test_auth_retrieve_3(self):
"""Retrieve method with unauthorized user; private dataset specified"""
self.silent_login(self.unauth_user, usrpw)
# inc = ["data_release", "ivar"]
#!drs = ["DESI-EDR", "SDSS-DR17-test"]
#!uuids = self.uuid_desiedr + self.uuid_priv
# Replace exception name below once real one is created
# @@@ Replace exception name below once real one is created
with self.assertRaises(ex.UnknownServerError):
self.client.retrieve(
uuid_list=self.uuid_privpub,
Expand All @@ -1001,19 +993,12 @@ def test_auth_retrieve_3(self):
)
self.silent_logout()

# | retrieve | Unauth | None|
# Should PASS since default (no data sets) means only
# retrieve from authorized datasets (Public, in this case)
# | retrieve | Unauth | None |
def test_auth_retrieve_4(self):
"""Retrieve method with unauthorized user; no datasets specified"""
self.silent_login(self.unauth_user, usrpw)
#!inc = ["data_release", "wave_sigma"]
#!# Replace exception name below once real one is created
#!with self.assertRaises(ex.UnknownServerError):
#! self.client.retrieve(uuid_list=self.uuid_all, include=inc)

got = self.client.retrieve(uuid_list=self.uuid_all, include=self.inc)
actual = got
actual = [f'{r.data_release}, {len(r.flux)} ; ' for r in got.records]
if showact:
print(f"auth_retrieve_4: {pf(actual)=}")
self.assertEqual(actual, exp.auth_retrieve_4, msg="Actual to Expected")
Expand All @@ -1023,19 +1008,10 @@ def test_auth_retrieve_4(self):
def test_auth_retrieve_5(self):
"""Retrieve method with unauthorized user; public datasets specified"""
self.silent_login(self.unauth_user, usrpw)
#!inc = ["data_release", "wave_sigma"]
#!drs = ["SDSS-DR16", "DESI-EDR"]
#!uuids = self.uuid_pub + self.uuid_desiedr # self.uuid_pub @@@
got = self.client.retrieve(
uuid_list=self.uuid_pub, include=self.inc, dataset_list=self.Pub
)
actual = ""
for rec in got.records:
actual1 = rec.data_release + ", " + str(len(rec.flux)) + " ; "
actual = actual + actual1
# BETTER of above: @@@
# actual = [f'{r.data_release}, {len(r.flux)} ; ' for r in got.records]

actual = [f'{r.data_release}, {len(r.flux)} ; ' for r in got.records]
if showact:
print(f"auth_retrieve_5: actual={pf(actual)}")
self.assertEqual(actual, exp.auth_retrieve_5, msg="Actual to Expected")
Expand All @@ -1045,11 +1021,7 @@ def test_auth_retrieve_5(self):
def test_auth_retrieve_6(self):
"""Retrieve method with anonymous user; private data set specified"""
self.silent_logout()
#!inc = ["data_release", "flux"]
#!drs = ["SDSS-DR17-test", "BOSS-DR16"]
#!drs = self.PrivPub
#!uuids = self.uuid_priv + self.uuid_bossdr16
# Replace exception name below once real one is created
# @@@ Replace exception name below once real one is created
with self.assertRaises(ex.UnknownServerError):
self.client.retrieve(
uuid_list=self.uuid_privpub, # uuids,
Expand All @@ -1058,18 +1030,11 @@ def test_auth_retrieve_6(self):
)

# | retrieve | Anon | None |
# Should PASS since default (no data sets) means only
# retrieve from authorized datasets (Public, in this case)
def test_auth_retrieve_7(self):
"""Retrieve method with anonymous user; no data sets specified"""
self.silent_logout()
#!inc = ["data_release", "model"]
# Replace exception name below once real one is created
#! with self.assertRaises(ex.UnknownServerError):
#! self.client.retrieve(uuid_list=self.uuid_all, include=inc)

got = self.client.retrieve(uuid_list=self.uuid_all, include=self.inc)
actual = got
actual = [f'{r.data_release}, {len(r.flux)} ; ' for r in got.records]
if showact:
print(f"auth_retrieve_7: {pf(actual)=}")
self.assertEqual(actual, exp.auth_retrieve_7, msg="Actual to Expected")
Expand All @@ -1079,16 +1044,10 @@ def test_auth_retrieve_7(self):
def test_auth_retrieve_8(self):
"""Retrieve method with anonymous user; public data sets specified"""
self.silent_logout()
#!inc = ["data_release", "model"]
#!drs = ["SDSS-DR16", "BOSS-DR16"]
#!uuids = self.uuid_pub + self.uuid_bossdr16
got = self.client.retrieve(
include=self.inc, uuid_list=self.uuid_pub, dataset_list=self.Pub
)
actual = ""
for rec in got.records:
actual1 = rec.data_release + ", " + str(len(rec.flux)) + " ; "
actual = actual + actual1
actual = [f'{r.data_release}, {len(r.flux)} ; ' for r in got.records]
if showact:
print(f"auth_retrieve_8: actual={pf(actual)}")
self.assertEqual(actual, exp.auth_retrieve_8, msg="Actual to Expected")
Loading