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

exclude UNPUBLISHED and add test for SSO #38

Merged
merged 3 commits into from
Jun 3, 2024
Merged

exclude UNPUBLISHED and add test for SSO #38

merged 3 commits into from
Jun 3, 2024

Conversation

pothiers
Copy link
Collaborator

Deploy to PyPi should exclude notebooks/UNPLUBLISHED/ directory so that something like pip install sparclclient==1.2.2b9 will not install the UNBPUBLISHED directory. That dir is intended to contain notebooks we find useful but are not appropriate for general user. NOTE: the directory content will still be available via the repo so it should be ok for anyone to see it; just not useful.

This also adds test_get_token. The test will fail with appropriate message output when (for instance) SSO has bad CERTS and does not work.

@pothiers pothiers changed the title do not put UNPUBLISHED in distro; add test for get_token to verify SSO exclude UNPUBLISHED and add test for SSO May 23, 2024
Copy link
Member

@jacquesalice jacquesalice left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@pothiers I get several failures when running tests on both PAT and my DEV:

PAT:

Arranging to run doctests against: sparcl.client
Arranging to run doctests against: sparcl.gather_2d
sssssssRunning Client Tests
  against Server: "sparc1.datalab.noirlab.edu"
  comparing to: tests.expected_pat
  showact=False
  showcurl=False
  client=(sparclclient:1.2.2b9, api:11.0, https://sparc1.datalab.noirlab.edu/sparc, client_hash=, verbose=False,
 connect_timeout=1.1, read_timeout=5400.0)

.................Fs...s..sss.........................F....
======================================================================
FAIL: test_get_token (tests.tests_api.AuthTest)
Make sure we can get expected SSO token.
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/ajacques/sparclclient/tests/tests_api.py", line 858, in test_get_token
    self.assertEqual(res, expected, msg="Actual to Expected")
AssertionError: <Response [200]> != '' : Actual to Expected

======================================================================
FAIL: missing_specids (sparcl.client.SparclClient)
Doctest: sparcl.client.SparclClient.missing_specids
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/usr/local/lib/python3.10/doctest.py", line 2217, in runTest
    raise self.failureException(self.format_failure(new.getvalue()))
AssertionError: Failed doctest test for sparcl.client.SparclClient.missing_specids
  File "/home/ajacques/sparclclient/sparcl/client.py", line 638, in missing_specids
----------------------------------------------------------------------                                          
File "/home/ajacques/sparclclient/sparcl/client.py", line 661, in sparcl.client.SparclClient.missing_specids    
Failed example:                                                                                                 
    client = SparclClient(url=_DEV)                                                                             
Exception raised:
Traceback (most recent call last):
File "/usr/local/lib/python3.10/doctest.py", line 1346, in __run
exec(compile(example.source, filename, "single",
File "<doctest sparcl.client.SparclClient.missing_specids[0]>", line 1, in <module>
client = SparclClient(url=_DEV)
File "/home/ajacques/sparclclient/sparcl/client.py", line 210, in __init__
raise ex.ServerConnectionError(msg) from None  # disable chaining
sparcl.exceptions.ServerConnectionError: [SRVCONER] Could not connect to http://localhost:8050/sparc/version/. HTTPConnectionPool(host='localhost', port=8050): Max retries exceeded with url: /sparc/version/ (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x7fd1bfa76aa0>: Failed to establish a new connection: [Errno 111] Connection refused'))
----------------------------------------------------------------------
File "/home/ajacques/sparclclient/sparcl/client.py", line 662, in sparcl.client.SparclClient.missing_specids
Failed example:
found = client.find(outfields=['specid'], limit=2)
Exception raised:
Traceback (most recent call last):
File "/usr/local/lib/python3.10/doctest.py", line 1346, in __run
exec(compile(example.source, filename, "single",
File "<doctest sparcl.client.SparclClient.missing_specids[1]>", line 1, in <module>
found = client.find(outfields=['specid'], limit=2)
NameError: name 'client' is not defined
----------------------------------------------------------------------
File "/home/ajacques/sparclclient/sparcl/client.py", line 663, in sparcl.client.SparclClient.missing_specids
Failed example:
specids = [f.specid for f in found.records]
Exception raised:
Traceback (most recent call last):
File "/usr/local/lib/python3.10/doctest.py", line 1346, in __run
exec(compile(example.source, filename, "single",
File "<doctest sparcl.client.SparclClient.missing_specids[2]>", line 1, in <module>
specids = [f.specid for f in found.records]
NameError: name 'found' is not defined
----------------------------------------------------------------------
File "/home/ajacques/sparclclient/sparcl/client.py", line 664, in sparcl.client.SparclClient.missing_specids
Failed example:
client.missing_specids(specids + ['bad_id'])
Exception raised:
Traceback (most recent call last):
File "/usr/local/lib/python3.10/doctest.py", line 1346, in __run
exec(compile(example.source, filename, "single",
File "<doctest sparcl.client.SparclClient.missing_specids[3]>", line 1, in <module>                               client.missing_specids(specids + ['bad_id'])

My DEV:

Arranging to run doctests against: sparcl.client
Arranging to run doctests against: sparcl.gather_2d
sssssssRunning Client Tests
against Server: "sparcdev2.csdc.noirlab.edu:8050"
comparing to: tests.expected_pat
showact=False
showcurl=False
client=(sparclclient:1.2.2b9, api:11.0, http://sparcdev2.csdc.noirlab.edu:8050/sparc, client_hash=, verbose=False, connect_timeout=1.1, read_timeout=5400.0)
.................Fs...s..sss.........................F....
======================================================================                                          FAIL: test_get_token (tests.tests_api.AuthTest)
Make sure we can get expected SSO token.
----------------------------------------------------------------------
Traceback (most recent call last):
File "/home/ajacques/sparclclient/tests/tests_api.py", line 858, in test_get_token
self.assertEqual(res, expected, msg="Actual to Expected")
AssertionError: <Response [200]> != '' : Actual to Expected
======================================================================
FAIL: missing_specids (sparcl.client.SparclClient)
Doctest: sparcl.client.SparclClient.missing_specids
----------------------------------------------------------------------
Traceback (most recent call last):
File "/usr/local/lib/python3.10/doctest.py", line 2217, in runTest
raise self.failureException(self.format_failure(new.getvalue()))
AssertionError: Failed doctest test for sparcl.client.SparclClient.missing_specids
File "/home/ajacques/sparclclient/sparcl/client.py", line 638, in missing_specids
----------------------------------------------------------------------
File "/home/ajacques/sparclclient/sparcl/client.py", line 661, in sparcl.client.SparclClient.missing_specids
Failed example:
client = SparclClient(url=_DEV)
Exception raised:
Traceback (most recent call last):
File "/usr/local/lib/python3.10/doctest.py", line 1346, in __run
exec(compile(example.source, filename, "single",
File "<doctest sparcl.client.SparclClient.missing_specids[0]>", line 1, in <module>
client = SparclClient(url=_DEV)
File "/home/ajacques/sparclclient/sparcl/client.py", line 210, in __init__
raise ex.ServerConnectionError(msg) from None  # disable chaining
sparcl.exceptions.ServerConnectionError: [SRVCONER] Could not connect to http://localhost:8050/sparc/version/. HTTPConnectionPool(host='localhost', port=8050): Max retries exceeded with url: /sparc/version/ (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x7f7eddf7d990>: Failed to establish a new connection: [Errno 111] Connection refused'))
----------------------------------------------------------------------
File "/home/ajacques/sparclclient/sparcl/client.py", line 662, in sparcl.client.SparclClient.missing_specids
Failed example:
found = client.find(outfields=['specid'], limit=2)
Exception raised:
Traceback (most recent call last):
File "/usr/local/lib/python3.10/doctest.py", line 1346, in __run
exec(compile(example.source, filename, "single",
File "<doctest sparcl.client.SparclClient.missing_specids[1]>", line 1, in <module>
found = client.find(outfields=['specid'], limit=2)
NameError: name 'client' is not defined
----------------------------------------------------------------------
File "/home/ajacques/sparclclient/sparcl/client.py", line 663, in sparcl.client.SparclClient.missing_specids
Failed example:
specids = [f.specid for f in found.records]
Exception raised:
Traceback (most recent call last):
File "/usr/local/lib/python3.10/doctest.py", line 1346, in __run
exec(compile(example.source, filename, "single",
File "<doctest sparcl.client.SparclClient.missing_specids[2]>", line 1, in <module>
specids = [f.specid for f in found.records]
NameError: name 'found' is not defined
----------------------------------------------------------------------
File "/home/ajacques/sparclclient/sparcl/client.py", line 664, in sparcl.client.SparclClient.missing_specids
Failed example:
client.missing_specids(specids + ['bad_id'])
Exception raised:
Traceback (most recent call last):
File "/usr/local/lib/python3.10/doctest.py", line 1346, in __run
exec(compile(example.source, filename, "single",
File "<doctest sparcl.client.SparclClient.missing_specids[3]>", line 1, in <module>
client.missing_specids(specids + ['bad_id'])
NameError: name 'client' is not defined
----------------------------------------------------------------------
Ran 65 tests in 84.146s
FAILED (failures=2, skipped=12) 

@pothiers
Copy link
Collaborator Author

pothiers commented Jun 3, 2024

test and client updated to prevent attempt to do doctests unless running against PROD server.

@pothiers pothiers closed this Jun 3, 2024
@pothiers pothiers reopened this Jun 3, 2024
@jacquesalice
Copy link
Member

Thanks @pothiers ! Works now. I'll Approve and merge

@jacquesalice jacquesalice merged commit c26b4ee into main Jun 3, 2024
0 of 6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants