Files
specklepy/tests/unit/test_setup_session.py
Jedd Morgan 4bc95441b9
Publish Python Package / test (push) Has been cancelled
Publish Python Package / Build and Publish Python Package (push) Has been cancelled
feat(serverTransport): Add urlib3 retry policy to requests.Session clients used by ServerTransport (#461)
* Pre-commit on the public image

* change names

* first pass using urllib3 retry policy

* add some basic unit test

* correct the doc string
2025-10-15 21:43:45 +01:00

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"