-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
8bf4b1e
commit 8f47b14
Showing
3 changed files
with
55 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,6 +14,7 @@ | |
PASQAL_ENDPOINTS, | ||
SDK, | ||
) | ||
from pasqal_cloud._version import __version__ as sdk_version | ||
from pasqal_cloud.authentication import TokenProvider | ||
from tests.test_doubles.authentication import ( | ||
FakeAuth0AuthenticationFailure, | ||
|
@@ -442,3 +443,41 @@ def test_request_pagination_without_pagination_success( | |
) | ||
assert len(response) == 1 | ||
assert response == [{"id": 1}] | ||
|
||
class TestHeaders: | ||
@pytest.fixture(autouse=True) | ||
@patch( | ||
"pasqal_cloud.client.Auth0TokenProvider", | ||
FakeAuth0AuthenticationSuccess, | ||
) | ||
def _init_sdk(self): | ||
self.sdk = SDK( | ||
username="[email protected]", | ||
password="password", | ||
project_id=str(uuid4()), | ||
) | ||
|
||
def test_user_agent_in_request_headers( | ||
self, mock_request: Generator[Any, Any, None] | ||
): | ||
""" | ||
Test that the `_authenticated_request` method of | ||
the client injects the user-agent header properly | ||
in the headers. | ||
""" | ||
mock_request.reset_mock() | ||
mock_request.register_uri( | ||
"GET", | ||
"http://core-test.com", | ||
status_code=200, | ||
json={ | ||
"ok": True | ||
} | ||
) | ||
|
||
_ = self.sdk._client._authenticated_request( | ||
"GET", "http://core-test.com" | ||
) | ||
assert mock_request.last_request.headers["User-Agent"] == ( | ||
f"PasqalCloudSDK/{sdk_version}" | ||
) |