4bc95441b9
* Pre-commit on the public image * change names * first pass using urllib3 retry policy * add some basic unit test * correct the doc string
21 lines
705 B
Python
21 lines
705 B
Python
import requests
|
|
|
|
from specklepy.transports.server.retry_policy import setup_session
|
|
|
|
|
|
def test_session_headers_without_auth():
|
|
"""Check that Accept header is set and Authorization is not."""
|
|
session = setup_session(None)
|
|
assert isinstance(session, requests.Session)
|
|
assert session.headers["Accept"] == "text/plain"
|
|
assert "Authorization" not in session.headers
|
|
|
|
|
|
def test_session_headers_with_auth():
|
|
"""Check that Authorization header is properly added."""
|
|
token = "abc123"
|
|
session = setup_session(token)
|
|
assert isinstance(session, requests.Session)
|
|
assert session.headers["Authorization"] == f"Bearer {token}"
|
|
assert session.headers["Accept"] == "text/plain"
|