diff --git a/.stats.yml b/.stats.yml
index 681b4257..73df72e5 100644
--- a/.stats.yml
+++ b/.stats.yml
@@ -1,2 +1,2 @@
-configured_endpoints: 15
-openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/brainbase-egrigokhan%2Fbrainbase-a197a88d1abbdbd5c886875d2cf12ffd6abf79aec7d4dbd0439ed50197692eba.yml
+configured_endpoints: 14
+openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/brainbase-egrigokhan%2Fbrainbase-0c00485d66a3b7505f3247467ef293fa5fb43a64e90a8b03a4127a2d9b15e6ab.yml
diff --git a/README.md b/README.md
index d353b142..fe9edc6f 100644
--- a/README.md
+++ b/README.md
@@ -28,16 +28,16 @@ import os
from brainbase import Brainbase
client = Brainbase(
- bearer_token=os.environ.get("BEARER_TOKEN"), # This is the default and can be omitted
+ api_key=os.environ.get("API_KEY"), # This is the default and can be omitted
)
client.workers.list()
```
-While you can provide a `bearer_token` keyword argument,
+While you can provide an `api_key` keyword argument,
we recommend using [python-dotenv](https://pypi.org/project/python-dotenv/)
-to add `BEARER_TOKEN="My Bearer Token"` to your `.env` file
-so that your Bearer Token is not stored in source control.
+to add `API_KEY="My API Key"` to your `.env` file
+so that your API Key is not stored in source control.
## Async usage
@@ -49,7 +49,7 @@ import asyncio
from brainbase import AsyncBrainbase
client = AsyncBrainbase(
- bearer_token=os.environ.get("BEARER_TOKEN"), # This is the default and can be omitted
+ api_key=os.environ.get("API_KEY"), # This is the default and can be omitted
)
diff --git a/api.md b/api.md
index 2ef3de3f..77b07ee9 100644
--- a/api.md
+++ b/api.md
@@ -2,11 +2,10 @@
Methods:
-- client.workers.create(\*\*params) -> None
+- client.workers.create(id, \*\*params) -> None
- client.workers.retrieve(id) -> None
- client.workers.list() -> None
-- client.workers.create_id(id, \*\*params) -> None
-- client.workers.delete_id(id) -> None
+- client.workers.delete(id) -> None
## Deployments
diff --git a/src/brainbase/_client.py b/src/brainbase/_client.py
index 94046af3..c42e10d6 100644
--- a/src/brainbase/_client.py
+++ b/src/brainbase/_client.py
@@ -51,12 +51,12 @@ class Brainbase(SyncAPIClient):
with_streaming_response: BrainbaseWithStreamedResponse
# client options
- bearer_token: str
+ api_key: str
def __init__(
self,
*,
- bearer_token: str | None = None,
+ api_key: str | None = None,
base_url: str | httpx.URL | None = None,
timeout: Union[float, Timeout, None, NotGiven] = NOT_GIVEN,
max_retries: int = DEFAULT_MAX_RETRIES,
@@ -78,15 +78,15 @@ def __init__(
) -> None:
"""Construct a new synchronous brainbase client instance.
- This automatically infers the `bearer_token` argument from the `BEARER_TOKEN` environment variable if it is not provided.
+ This automatically infers the `api_key` argument from the `API_KEY` environment variable if it is not provided.
"""
- if bearer_token is None:
- bearer_token = os.environ.get("BEARER_TOKEN")
- if bearer_token is None:
+ if api_key is None:
+ api_key = os.environ.get("API_KEY")
+ if api_key is None:
raise BrainbaseError(
- "The bearer_token client option must be set either by passing bearer_token to the client or by setting the BEARER_TOKEN environment variable"
+ "The api_key client option must be set either by passing api_key to the client or by setting the API_KEY environment variable"
)
- self.bearer_token = bearer_token
+ self.api_key = api_key
if base_url is None:
base_url = os.environ.get("BRAINBASE_BASE_URL")
@@ -116,8 +116,8 @@ def qs(self) -> Querystring:
@property
@override
def auth_headers(self) -> dict[str, str]:
- bearer_token = self.bearer_token
- return {"Authorization": f"Bearer {bearer_token}"}
+ api_key = self.api_key
+ return {"x-api-key": api_key}
@property
@override
@@ -131,7 +131,7 @@ def default_headers(self) -> dict[str, str | Omit]:
def copy(
self,
*,
- bearer_token: str | None = None,
+ api_key: str | None = None,
base_url: str | httpx.URL | None = None,
timeout: float | Timeout | None | NotGiven = NOT_GIVEN,
http_client: httpx.Client | None = None,
@@ -165,7 +165,7 @@ def copy(
http_client = http_client or self._client
return self.__class__(
- bearer_token=bearer_token or self.bearer_token,
+ api_key=api_key or self.api_key,
base_url=base_url or self.base_url,
timeout=self.timeout if isinstance(timeout, NotGiven) else timeout,
http_client=http_client,
@@ -219,12 +219,12 @@ class AsyncBrainbase(AsyncAPIClient):
with_streaming_response: AsyncBrainbaseWithStreamedResponse
# client options
- bearer_token: str
+ api_key: str
def __init__(
self,
*,
- bearer_token: str | None = None,
+ api_key: str | None = None,
base_url: str | httpx.URL | None = None,
timeout: Union[float, Timeout, None, NotGiven] = NOT_GIVEN,
max_retries: int = DEFAULT_MAX_RETRIES,
@@ -246,15 +246,15 @@ def __init__(
) -> None:
"""Construct a new async brainbase client instance.
- This automatically infers the `bearer_token` argument from the `BEARER_TOKEN` environment variable if it is not provided.
+ This automatically infers the `api_key` argument from the `API_KEY` environment variable if it is not provided.
"""
- if bearer_token is None:
- bearer_token = os.environ.get("BEARER_TOKEN")
- if bearer_token is None:
+ if api_key is None:
+ api_key = os.environ.get("API_KEY")
+ if api_key is None:
raise BrainbaseError(
- "The bearer_token client option must be set either by passing bearer_token to the client or by setting the BEARER_TOKEN environment variable"
+ "The api_key client option must be set either by passing api_key to the client or by setting the API_KEY environment variable"
)
- self.bearer_token = bearer_token
+ self.api_key = api_key
if base_url is None:
base_url = os.environ.get("BRAINBASE_BASE_URL")
@@ -284,8 +284,8 @@ def qs(self) -> Querystring:
@property
@override
def auth_headers(self) -> dict[str, str]:
- bearer_token = self.bearer_token
- return {"Authorization": f"Bearer {bearer_token}"}
+ api_key = self.api_key
+ return {"x-api-key": api_key}
@property
@override
@@ -299,7 +299,7 @@ def default_headers(self) -> dict[str, str | Omit]:
def copy(
self,
*,
- bearer_token: str | None = None,
+ api_key: str | None = None,
base_url: str | httpx.URL | None = None,
timeout: float | Timeout | None | NotGiven = NOT_GIVEN,
http_client: httpx.AsyncClient | None = None,
@@ -333,7 +333,7 @@ def copy(
http_client = http_client or self._client
return self.__class__(
- bearer_token=bearer_token or self.bearer_token,
+ api_key=api_key or self.api_key,
base_url=base_url or self.base_url,
timeout=self.timeout if isinstance(timeout, NotGiven) else timeout,
http_client=http_client,
diff --git a/src/brainbase/resources/workers/workers.py b/src/brainbase/resources/workers/workers.py
index ca7e4c4b..eb3d3e1c 100644
--- a/src/brainbase/resources/workers/workers.py
+++ b/src/brainbase/resources/workers/workers.py
@@ -12,7 +12,7 @@
FlowsResourceWithStreamingResponse,
AsyncFlowsResourceWithStreamingResponse,
)
-from ...types import worker_create_params, worker_create_id_params
+from ...types import worker_create_params
from ..._types import NOT_GIVEN, Body, Query, Headers, NoneType, NotGiven
from ..._utils import (
maybe_transform,
@@ -69,9 +69,10 @@ def with_streaming_response(self) -> WorkersResourceWithStreamingResponse:
def create(
self,
+ id: str,
*,
- name: str,
description: str | NotGiven = NOT_GIVEN,
+ name: str | NotGiven = NOT_GIVEN,
status: str | NotGiven = NOT_GIVEN,
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
# The extra values given here take precedence over values defined on the client or passed to this method.
@@ -81,7 +82,7 @@ def create(
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
) -> None:
"""
- Create a new worker
+ Update a worker
Args:
extra_headers: Send extra headers
@@ -92,13 +93,15 @@ def create(
timeout: Override the client-level default timeout for this request, in seconds
"""
+ if not id:
+ raise ValueError(f"Expected a non-empty value for `id` but received {id!r}")
extra_headers = {"Accept": "*/*", **(extra_headers or {})}
return self._post(
- "/api/workers",
+ f"/api/workers/{id}",
body=maybe_transform(
{
- "name": name,
"description": description,
+ "name": name,
"status": status,
},
worker_create_params.WorkerCreateParams,
@@ -163,52 +166,7 @@ def list(
cast_to=NoneType,
)
- def create_id(
- self,
- id: str,
- *,
- description: str | NotGiven = NOT_GIVEN,
- name: str | NotGiven = NOT_GIVEN,
- status: str | NotGiven = NOT_GIVEN,
- # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
- # The extra values given here take precedence over values defined on the client or passed to this method.
- extra_headers: Headers | None = None,
- extra_query: Query | None = None,
- extra_body: Body | None = None,
- timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
- ) -> None:
- """
- Update a worker
-
- Args:
- extra_headers: Send extra headers
-
- extra_query: Add additional query parameters to the request
-
- extra_body: Add additional JSON properties to the request
-
- timeout: Override the client-level default timeout for this request, in seconds
- """
- if not id:
- raise ValueError(f"Expected a non-empty value for `id` but received {id!r}")
- extra_headers = {"Accept": "*/*", **(extra_headers or {})}
- return self._post(
- f"/api/workers/{id}",
- body=maybe_transform(
- {
- "description": description,
- "name": name,
- "status": status,
- },
- worker_create_id_params.WorkerCreateIDParams,
- ),
- options=make_request_options(
- extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
- ),
- cast_to=NoneType,
- )
-
- def delete_id(
+ def delete(
self,
id: str,
*,
@@ -273,9 +231,10 @@ def with_streaming_response(self) -> AsyncWorkersResourceWithStreamingResponse:
async def create(
self,
+ id: str,
*,
- name: str,
description: str | NotGiven = NOT_GIVEN,
+ name: str | NotGiven = NOT_GIVEN,
status: str | NotGiven = NOT_GIVEN,
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
# The extra values given here take precedence over values defined on the client or passed to this method.
@@ -285,7 +244,7 @@ async def create(
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
) -> None:
"""
- Create a new worker
+ Update a worker
Args:
extra_headers: Send extra headers
@@ -296,13 +255,15 @@ async def create(
timeout: Override the client-level default timeout for this request, in seconds
"""
+ if not id:
+ raise ValueError(f"Expected a non-empty value for `id` but received {id!r}")
extra_headers = {"Accept": "*/*", **(extra_headers or {})}
return await self._post(
- "/api/workers",
+ f"/api/workers/{id}",
body=await async_maybe_transform(
{
- "name": name,
"description": description,
+ "name": name,
"status": status,
},
worker_create_params.WorkerCreateParams,
@@ -367,52 +328,7 @@ async def list(
cast_to=NoneType,
)
- async def create_id(
- self,
- id: str,
- *,
- description: str | NotGiven = NOT_GIVEN,
- name: str | NotGiven = NOT_GIVEN,
- status: str | NotGiven = NOT_GIVEN,
- # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
- # The extra values given here take precedence over values defined on the client or passed to this method.
- extra_headers: Headers | None = None,
- extra_query: Query | None = None,
- extra_body: Body | None = None,
- timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
- ) -> None:
- """
- Update a worker
-
- Args:
- extra_headers: Send extra headers
-
- extra_query: Add additional query parameters to the request
-
- extra_body: Add additional JSON properties to the request
-
- timeout: Override the client-level default timeout for this request, in seconds
- """
- if not id:
- raise ValueError(f"Expected a non-empty value for `id` but received {id!r}")
- extra_headers = {"Accept": "*/*", **(extra_headers or {})}
- return await self._post(
- f"/api/workers/{id}",
- body=await async_maybe_transform(
- {
- "description": description,
- "name": name,
- "status": status,
- },
- worker_create_id_params.WorkerCreateIDParams,
- ),
- options=make_request_options(
- extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
- ),
- cast_to=NoneType,
- )
-
- async def delete_id(
+ async def delete(
self,
id: str,
*,
@@ -460,11 +376,8 @@ def __init__(self, workers: WorkersResource) -> None:
self.list = to_raw_response_wrapper(
workers.list,
)
- self.create_id = to_raw_response_wrapper(
- workers.create_id,
- )
- self.delete_id = to_raw_response_wrapper(
- workers.delete_id,
+ self.delete = to_raw_response_wrapper(
+ workers.delete,
)
@cached_property
@@ -489,11 +402,8 @@ def __init__(self, workers: AsyncWorkersResource) -> None:
self.list = async_to_raw_response_wrapper(
workers.list,
)
- self.create_id = async_to_raw_response_wrapper(
- workers.create_id,
- )
- self.delete_id = async_to_raw_response_wrapper(
- workers.delete_id,
+ self.delete = async_to_raw_response_wrapper(
+ workers.delete,
)
@cached_property
@@ -518,11 +428,8 @@ def __init__(self, workers: WorkersResource) -> None:
self.list = to_streamed_response_wrapper(
workers.list,
)
- self.create_id = to_streamed_response_wrapper(
- workers.create_id,
- )
- self.delete_id = to_streamed_response_wrapper(
- workers.delete_id,
+ self.delete = to_streamed_response_wrapper(
+ workers.delete,
)
@cached_property
@@ -547,11 +454,8 @@ def __init__(self, workers: AsyncWorkersResource) -> None:
self.list = async_to_streamed_response_wrapper(
workers.list,
)
- self.create_id = async_to_streamed_response_wrapper(
- workers.create_id,
- )
- self.delete_id = async_to_streamed_response_wrapper(
- workers.delete_id,
+ self.delete = async_to_streamed_response_wrapper(
+ workers.delete,
)
@cached_property
diff --git a/src/brainbase/types/__init__.py b/src/brainbase/types/__init__.py
index fa40311b..5976bd7c 100644
--- a/src/brainbase/types/__init__.py
+++ b/src/brainbase/types/__init__.py
@@ -3,4 +3,3 @@
from __future__ import annotations
from .worker_create_params import WorkerCreateParams as WorkerCreateParams
-from .worker_create_id_params import WorkerCreateIDParams as WorkerCreateIDParams
diff --git a/src/brainbase/types/worker_create_id_params.py b/src/brainbase/types/worker_create_id_params.py
deleted file mode 100644
index df526612..00000000
--- a/src/brainbase/types/worker_create_id_params.py
+++ /dev/null
@@ -1,15 +0,0 @@
-# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
-
-from __future__ import annotations
-
-from typing_extensions import TypedDict
-
-__all__ = ["WorkerCreateIDParams"]
-
-
-class WorkerCreateIDParams(TypedDict, total=False):
- description: str
-
- name: str
-
- status: str
diff --git a/src/brainbase/types/worker_create_params.py b/src/brainbase/types/worker_create_params.py
index 757c0420..f84e516c 100644
--- a/src/brainbase/types/worker_create_params.py
+++ b/src/brainbase/types/worker_create_params.py
@@ -2,14 +2,14 @@
from __future__ import annotations
-from typing_extensions import Required, TypedDict
+from typing_extensions import TypedDict
__all__ = ["WorkerCreateParams"]
class WorkerCreateParams(TypedDict, total=False):
- name: Required[str]
-
description: str
+ name: str
+
status: str
diff --git a/tests/api_resources/test_workers.py b/tests/api_resources/test_workers.py
index 41555aa3..a6c4d926 100644
--- a/tests/api_resources/test_workers.py
+++ b/tests/api_resources/test_workers.py
@@ -19,7 +19,7 @@ class TestWorkers:
@parametrize
def test_method_create(self, client: Brainbase) -> None:
worker = client.workers.create(
- name="name",
+ id="id",
)
assert worker is None
@@ -27,8 +27,9 @@ def test_method_create(self, client: Brainbase) -> None:
@parametrize
def test_method_create_with_all_params(self, client: Brainbase) -> None:
worker = client.workers.create(
- name="name",
+ id="id",
description="description",
+ name="name",
status="status",
)
assert worker is None
@@ -37,7 +38,7 @@ def test_method_create_with_all_params(self, client: Brainbase) -> None:
@parametrize
def test_raw_response_create(self, client: Brainbase) -> None:
response = client.workers.with_raw_response.create(
- name="name",
+ id="id",
)
assert response.is_closed is True
@@ -49,7 +50,7 @@ def test_raw_response_create(self, client: Brainbase) -> None:
@parametrize
def test_streaming_response_create(self, client: Brainbase) -> None:
with client.workers.with_streaming_response.create(
- name="name",
+ id="id",
) as response:
assert not response.is_closed
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
@@ -59,6 +60,14 @@ def test_streaming_response_create(self, client: Brainbase) -> None:
assert cast(Any, response.is_closed) is True
+ @pytest.mark.skip()
+ @parametrize
+ def test_path_params_create(self, client: Brainbase) -> None:
+ with pytest.raises(ValueError, match=r"Expected a non-empty value for `id` but received ''"):
+ client.workers.with_raw_response.create(
+ id="",
+ )
+
@pytest.mark.skip()
@parametrize
def test_method_retrieve(self, client: Brainbase) -> None:
@@ -131,69 +140,16 @@ def test_streaming_response_list(self, client: Brainbase) -> None:
@pytest.mark.skip()
@parametrize
- def test_method_create_id(self, client: Brainbase) -> None:
- worker = client.workers.create_id(
- id="id",
- )
- assert worker is None
-
- @pytest.mark.skip()
- @parametrize
- def test_method_create_id_with_all_params(self, client: Brainbase) -> None:
- worker = client.workers.create_id(
- id="id",
- description="description",
- name="name",
- status="status",
- )
- assert worker is None
-
- @pytest.mark.skip()
- @parametrize
- def test_raw_response_create_id(self, client: Brainbase) -> None:
- response = client.workers.with_raw_response.create_id(
- id="id",
- )
-
- assert response.is_closed is True
- assert response.http_request.headers.get("X-Stainless-Lang") == "python"
- worker = response.parse()
- assert worker is None
-
- @pytest.mark.skip()
- @parametrize
- def test_streaming_response_create_id(self, client: Brainbase) -> None:
- with client.workers.with_streaming_response.create_id(
- id="id",
- ) as response:
- assert not response.is_closed
- assert response.http_request.headers.get("X-Stainless-Lang") == "python"
-
- worker = response.parse()
- assert worker is None
-
- assert cast(Any, response.is_closed) is True
-
- @pytest.mark.skip()
- @parametrize
- def test_path_params_create_id(self, client: Brainbase) -> None:
- with pytest.raises(ValueError, match=r"Expected a non-empty value for `id` but received ''"):
- client.workers.with_raw_response.create_id(
- id="",
- )
-
- @pytest.mark.skip()
- @parametrize
- def test_method_delete_id(self, client: Brainbase) -> None:
- worker = client.workers.delete_id(
+ def test_method_delete(self, client: Brainbase) -> None:
+ worker = client.workers.delete(
"id",
)
assert worker is None
@pytest.mark.skip()
@parametrize
- def test_raw_response_delete_id(self, client: Brainbase) -> None:
- response = client.workers.with_raw_response.delete_id(
+ def test_raw_response_delete(self, client: Brainbase) -> None:
+ response = client.workers.with_raw_response.delete(
"id",
)
@@ -204,8 +160,8 @@ def test_raw_response_delete_id(self, client: Brainbase) -> None:
@pytest.mark.skip()
@parametrize
- def test_streaming_response_delete_id(self, client: Brainbase) -> None:
- with client.workers.with_streaming_response.delete_id(
+ def test_streaming_response_delete(self, client: Brainbase) -> None:
+ with client.workers.with_streaming_response.delete(
"id",
) as response:
assert not response.is_closed
@@ -218,9 +174,9 @@ def test_streaming_response_delete_id(self, client: Brainbase) -> None:
@pytest.mark.skip()
@parametrize
- def test_path_params_delete_id(self, client: Brainbase) -> None:
+ def test_path_params_delete(self, client: Brainbase) -> None:
with pytest.raises(ValueError, match=r"Expected a non-empty value for `id` but received ''"):
- client.workers.with_raw_response.delete_id(
+ client.workers.with_raw_response.delete(
"",
)
@@ -232,7 +188,7 @@ class TestAsyncWorkers:
@parametrize
async def test_method_create(self, async_client: AsyncBrainbase) -> None:
worker = await async_client.workers.create(
- name="name",
+ id="id",
)
assert worker is None
@@ -240,8 +196,9 @@ async def test_method_create(self, async_client: AsyncBrainbase) -> None:
@parametrize
async def test_method_create_with_all_params(self, async_client: AsyncBrainbase) -> None:
worker = await async_client.workers.create(
- name="name",
+ id="id",
description="description",
+ name="name",
status="status",
)
assert worker is None
@@ -250,7 +207,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncBrainbase)
@parametrize
async def test_raw_response_create(self, async_client: AsyncBrainbase) -> None:
response = await async_client.workers.with_raw_response.create(
- name="name",
+ id="id",
)
assert response.is_closed is True
@@ -262,7 +219,7 @@ async def test_raw_response_create(self, async_client: AsyncBrainbase) -> None:
@parametrize
async def test_streaming_response_create(self, async_client: AsyncBrainbase) -> None:
async with async_client.workers.with_streaming_response.create(
- name="name",
+ id="id",
) as response:
assert not response.is_closed
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
@@ -272,6 +229,14 @@ async def test_streaming_response_create(self, async_client: AsyncBrainbase) ->
assert cast(Any, response.is_closed) is True
+ @pytest.mark.skip()
+ @parametrize
+ async def test_path_params_create(self, async_client: AsyncBrainbase) -> None:
+ with pytest.raises(ValueError, match=r"Expected a non-empty value for `id` but received ''"):
+ await async_client.workers.with_raw_response.create(
+ id="",
+ )
+
@pytest.mark.skip()
@parametrize
async def test_method_retrieve(self, async_client: AsyncBrainbase) -> None:
@@ -344,69 +309,16 @@ async def test_streaming_response_list(self, async_client: AsyncBrainbase) -> No
@pytest.mark.skip()
@parametrize
- async def test_method_create_id(self, async_client: AsyncBrainbase) -> None:
- worker = await async_client.workers.create_id(
- id="id",
- )
- assert worker is None
-
- @pytest.mark.skip()
- @parametrize
- async def test_method_create_id_with_all_params(self, async_client: AsyncBrainbase) -> None:
- worker = await async_client.workers.create_id(
- id="id",
- description="description",
- name="name",
- status="status",
- )
- assert worker is None
-
- @pytest.mark.skip()
- @parametrize
- async def test_raw_response_create_id(self, async_client: AsyncBrainbase) -> None:
- response = await async_client.workers.with_raw_response.create_id(
- id="id",
- )
-
- assert response.is_closed is True
- assert response.http_request.headers.get("X-Stainless-Lang") == "python"
- worker = await response.parse()
- assert worker is None
-
- @pytest.mark.skip()
- @parametrize
- async def test_streaming_response_create_id(self, async_client: AsyncBrainbase) -> None:
- async with async_client.workers.with_streaming_response.create_id(
- id="id",
- ) as response:
- assert not response.is_closed
- assert response.http_request.headers.get("X-Stainless-Lang") == "python"
-
- worker = await response.parse()
- assert worker is None
-
- assert cast(Any, response.is_closed) is True
-
- @pytest.mark.skip()
- @parametrize
- async def test_path_params_create_id(self, async_client: AsyncBrainbase) -> None:
- with pytest.raises(ValueError, match=r"Expected a non-empty value for `id` but received ''"):
- await async_client.workers.with_raw_response.create_id(
- id="",
- )
-
- @pytest.mark.skip()
- @parametrize
- async def test_method_delete_id(self, async_client: AsyncBrainbase) -> None:
- worker = await async_client.workers.delete_id(
+ async def test_method_delete(self, async_client: AsyncBrainbase) -> None:
+ worker = await async_client.workers.delete(
"id",
)
assert worker is None
@pytest.mark.skip()
@parametrize
- async def test_raw_response_delete_id(self, async_client: AsyncBrainbase) -> None:
- response = await async_client.workers.with_raw_response.delete_id(
+ async def test_raw_response_delete(self, async_client: AsyncBrainbase) -> None:
+ response = await async_client.workers.with_raw_response.delete(
"id",
)
@@ -417,8 +329,8 @@ async def test_raw_response_delete_id(self, async_client: AsyncBrainbase) -> Non
@pytest.mark.skip()
@parametrize
- async def test_streaming_response_delete_id(self, async_client: AsyncBrainbase) -> None:
- async with async_client.workers.with_streaming_response.delete_id(
+ async def test_streaming_response_delete(self, async_client: AsyncBrainbase) -> None:
+ async with async_client.workers.with_streaming_response.delete(
"id",
) as response:
assert not response.is_closed
@@ -431,8 +343,8 @@ async def test_streaming_response_delete_id(self, async_client: AsyncBrainbase)
@pytest.mark.skip()
@parametrize
- async def test_path_params_delete_id(self, async_client: AsyncBrainbase) -> None:
+ async def test_path_params_delete(self, async_client: AsyncBrainbase) -> None:
with pytest.raises(ValueError, match=r"Expected a non-empty value for `id` but received ''"):
- await async_client.workers.with_raw_response.delete_id(
+ await async_client.workers.with_raw_response.delete(
"",
)
diff --git a/tests/conftest.py b/tests/conftest.py
index 9a8b7c7c..8e89d982 100644
--- a/tests/conftest.py
+++ b/tests/conftest.py
@@ -28,7 +28,7 @@ def pytest_collection_modifyitems(items: list[pytest.Function]) -> None:
base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010")
-bearer_token = "My Bearer Token"
+api_key = "My API Key"
@pytest.fixture(scope="session")
@@ -37,7 +37,7 @@ def client(request: FixtureRequest) -> Iterator[Brainbase]:
if not isinstance(strict, bool):
raise TypeError(f"Unexpected fixture parameter type {type(strict)}, expected {bool}")
- with Brainbase(base_url=base_url, bearer_token=bearer_token, _strict_response_validation=strict) as client:
+ with Brainbase(base_url=base_url, api_key=api_key, _strict_response_validation=strict) as client:
yield client
@@ -47,7 +47,5 @@ async def async_client(request: FixtureRequest) -> AsyncIterator[AsyncBrainbase]
if not isinstance(strict, bool):
raise TypeError(f"Unexpected fixture parameter type {type(strict)}, expected {bool}")
- async with AsyncBrainbase(
- base_url=base_url, bearer_token=bearer_token, _strict_response_validation=strict
- ) as client:
+ async with AsyncBrainbase(base_url=base_url, api_key=api_key, _strict_response_validation=strict) as client:
yield client
diff --git a/tests/test_client.py b/tests/test_client.py
index 172269eb..c3570edb 100644
--- a/tests/test_client.py
+++ b/tests/test_client.py
@@ -36,7 +36,7 @@
from .utils import update_env
base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010")
-bearer_token = "My Bearer Token"
+api_key = "My API Key"
def _get_params(client: BaseClient[Any, Any]) -> dict[str, str]:
@@ -58,7 +58,7 @@ def _get_open_connections(client: Brainbase | AsyncBrainbase) -> int:
class TestBrainbase:
- client = Brainbase(base_url=base_url, bearer_token=bearer_token, _strict_response_validation=True)
+ client = Brainbase(base_url=base_url, api_key=api_key, _strict_response_validation=True)
@pytest.mark.respx(base_url=base_url)
def test_raw_response(self, respx_mock: MockRouter) -> None:
@@ -84,9 +84,9 @@ def test_copy(self) -> None:
copied = self.client.copy()
assert id(copied) != id(self.client)
- copied = self.client.copy(bearer_token="another My Bearer Token")
- assert copied.bearer_token == "another My Bearer Token"
- assert self.client.bearer_token == "My Bearer Token"
+ copied = self.client.copy(api_key="another My API Key")
+ assert copied.api_key == "another My API Key"
+ assert self.client.api_key == "My API Key"
def test_copy_default_options(self) -> None:
# options that have a default are overridden correctly
@@ -106,10 +106,7 @@ def test_copy_default_options(self) -> None:
def test_copy_default_headers(self) -> None:
client = Brainbase(
- base_url=base_url,
- bearer_token=bearer_token,
- _strict_response_validation=True,
- default_headers={"X-Foo": "bar"},
+ base_url=base_url, api_key=api_key, _strict_response_validation=True, default_headers={"X-Foo": "bar"}
)
assert client.default_headers["X-Foo"] == "bar"
@@ -143,7 +140,7 @@ def test_copy_default_headers(self) -> None:
def test_copy_default_query(self) -> None:
client = Brainbase(
- base_url=base_url, bearer_token=bearer_token, _strict_response_validation=True, default_query={"foo": "bar"}
+ base_url=base_url, api_key=api_key, _strict_response_validation=True, default_query={"foo": "bar"}
)
assert _get_params(client)["foo"] == "bar"
@@ -268,7 +265,7 @@ def test_request_timeout(self) -> None:
def test_client_timeout_option(self) -> None:
client = Brainbase(
- base_url=base_url, bearer_token=bearer_token, _strict_response_validation=True, timeout=httpx.Timeout(0)
+ base_url=base_url, api_key=api_key, _strict_response_validation=True, timeout=httpx.Timeout(0)
)
request = client._build_request(FinalRequestOptions(method="get", url="/foo"))
@@ -279,7 +276,7 @@ def test_http_client_timeout_option(self) -> None:
# custom timeout given to the httpx client should be used
with httpx.Client(timeout=None) as http_client:
client = Brainbase(
- base_url=base_url, bearer_token=bearer_token, _strict_response_validation=True, http_client=http_client
+ base_url=base_url, api_key=api_key, _strict_response_validation=True, http_client=http_client
)
request = client._build_request(FinalRequestOptions(method="get", url="/foo"))
@@ -289,7 +286,7 @@ def test_http_client_timeout_option(self) -> None:
# no timeout given to the httpx client should not use the httpx default
with httpx.Client() as http_client:
client = Brainbase(
- base_url=base_url, bearer_token=bearer_token, _strict_response_validation=True, http_client=http_client
+ base_url=base_url, api_key=api_key, _strict_response_validation=True, http_client=http_client
)
request = client._build_request(FinalRequestOptions(method="get", url="/foo"))
@@ -299,7 +296,7 @@ def test_http_client_timeout_option(self) -> None:
# explicitly passing the default timeout currently results in it being ignored
with httpx.Client(timeout=HTTPX_DEFAULT_TIMEOUT) as http_client:
client = Brainbase(
- base_url=base_url, bearer_token=bearer_token, _strict_response_validation=True, http_client=http_client
+ base_url=base_url, api_key=api_key, _strict_response_validation=True, http_client=http_client
)
request = client._build_request(FinalRequestOptions(method="get", url="/foo"))
@@ -311,17 +308,14 @@ async def test_invalid_http_client(self) -> None:
async with httpx.AsyncClient() as http_client:
Brainbase(
base_url=base_url,
- bearer_token=bearer_token,
+ api_key=api_key,
_strict_response_validation=True,
http_client=cast(Any, http_client),
)
def test_default_headers_option(self) -> None:
client = Brainbase(
- base_url=base_url,
- bearer_token=bearer_token,
- _strict_response_validation=True,
- default_headers={"X-Foo": "bar"},
+ base_url=base_url, api_key=api_key, _strict_response_validation=True, default_headers={"X-Foo": "bar"}
)
request = client._build_request(FinalRequestOptions(method="get", url="/foo"))
assert request.headers.get("x-foo") == "bar"
@@ -329,7 +323,7 @@ def test_default_headers_option(self) -> None:
client2 = Brainbase(
base_url=base_url,
- bearer_token=bearer_token,
+ api_key=api_key,
_strict_response_validation=True,
default_headers={
"X-Foo": "stainless",
@@ -341,21 +335,18 @@ def test_default_headers_option(self) -> None:
assert request.headers.get("x-stainless-lang") == "my-overriding-header"
def test_validate_headers(self) -> None:
- client = Brainbase(base_url=base_url, bearer_token=bearer_token, _strict_response_validation=True)
+ client = Brainbase(base_url=base_url, api_key=api_key, _strict_response_validation=True)
request = client._build_request(FinalRequestOptions(method="get", url="/foo"))
- assert request.headers.get("Authorization") == f"Bearer {bearer_token}"
+ assert request.headers.get("x-api-key") == api_key
with pytest.raises(BrainbaseError):
- with update_env(**{"BEARER_TOKEN": Omit()}):
- client2 = Brainbase(base_url=base_url, bearer_token=None, _strict_response_validation=True)
+ with update_env(**{"API_KEY": Omit()}):
+ client2 = Brainbase(base_url=base_url, api_key=None, _strict_response_validation=True)
_ = client2
def test_default_query_option(self) -> None:
client = Brainbase(
- base_url=base_url,
- bearer_token=bearer_token,
- _strict_response_validation=True,
- default_query={"query_param": "bar"},
+ base_url=base_url, api_key=api_key, _strict_response_validation=True, default_query={"query_param": "bar"}
)
request = client._build_request(FinalRequestOptions(method="get", url="/foo"))
url = httpx.URL(request.url)
@@ -555,9 +546,7 @@ class Model(BaseModel):
assert response.foo == 2
def test_base_url_setter(self) -> None:
- client = Brainbase(
- base_url="https://example.com/from_init", bearer_token=bearer_token, _strict_response_validation=True
- )
+ client = Brainbase(base_url="https://example.com/from_init", api_key=api_key, _strict_response_validation=True)
assert client.base_url == "https://example.com/from_init/"
client.base_url = "https://example.com/from_setter" # type: ignore[assignment]
@@ -566,20 +555,16 @@ def test_base_url_setter(self) -> None:
def test_base_url_env(self) -> None:
with update_env(BRAINBASE_BASE_URL="http://localhost:5000/from/env"):
- client = Brainbase(bearer_token=bearer_token, _strict_response_validation=True)
+ client = Brainbase(api_key=api_key, _strict_response_validation=True)
assert client.base_url == "http://localhost:5000/from/env/"
@pytest.mark.parametrize(
"client",
[
+ Brainbase(base_url="http://localhost:5000/custom/path/", api_key=api_key, _strict_response_validation=True),
Brainbase(
base_url="http://localhost:5000/custom/path/",
- bearer_token=bearer_token,
- _strict_response_validation=True,
- ),
- Brainbase(
- base_url="http://localhost:5000/custom/path/",
- bearer_token=bearer_token,
+ api_key=api_key,
_strict_response_validation=True,
http_client=httpx.Client(),
),
@@ -599,14 +584,10 @@ def test_base_url_trailing_slash(self, client: Brainbase) -> None:
@pytest.mark.parametrize(
"client",
[
+ Brainbase(base_url="http://localhost:5000/custom/path/", api_key=api_key, _strict_response_validation=True),
Brainbase(
base_url="http://localhost:5000/custom/path/",
- bearer_token=bearer_token,
- _strict_response_validation=True,
- ),
- Brainbase(
- base_url="http://localhost:5000/custom/path/",
- bearer_token=bearer_token,
+ api_key=api_key,
_strict_response_validation=True,
http_client=httpx.Client(),
),
@@ -626,14 +607,10 @@ def test_base_url_no_trailing_slash(self, client: Brainbase) -> None:
@pytest.mark.parametrize(
"client",
[
+ Brainbase(base_url="http://localhost:5000/custom/path/", api_key=api_key, _strict_response_validation=True),
Brainbase(
base_url="http://localhost:5000/custom/path/",
- bearer_token=bearer_token,
- _strict_response_validation=True,
- ),
- Brainbase(
- base_url="http://localhost:5000/custom/path/",
- bearer_token=bearer_token,
+ api_key=api_key,
_strict_response_validation=True,
http_client=httpx.Client(),
),
@@ -651,7 +628,7 @@ def test_absolute_request_url(self, client: Brainbase) -> None:
assert request.url == "https://myapi.com/foo"
def test_copied_client_does_not_close_http(self) -> None:
- client = Brainbase(base_url=base_url, bearer_token=bearer_token, _strict_response_validation=True)
+ client = Brainbase(base_url=base_url, api_key=api_key, _strict_response_validation=True)
assert not client.is_closed()
copied = client.copy()
@@ -662,7 +639,7 @@ def test_copied_client_does_not_close_http(self) -> None:
assert not client.is_closed()
def test_client_context_manager(self) -> None:
- client = Brainbase(base_url=base_url, bearer_token=bearer_token, _strict_response_validation=True)
+ client = Brainbase(base_url=base_url, api_key=api_key, _strict_response_validation=True)
with client as c2:
assert c2 is client
assert not c2.is_closed()
@@ -683,12 +660,7 @@ class Model(BaseModel):
def test_client_max_retries_validation(self) -> None:
with pytest.raises(TypeError, match=r"max_retries cannot be None"):
- Brainbase(
- base_url=base_url,
- bearer_token=bearer_token,
- _strict_response_validation=True,
- max_retries=cast(Any, None),
- )
+ Brainbase(base_url=base_url, api_key=api_key, _strict_response_validation=True, max_retries=cast(Any, None))
@pytest.mark.respx(base_url=base_url)
def test_received_text_for_expected_json(self, respx_mock: MockRouter) -> None:
@@ -697,12 +669,12 @@ class Model(BaseModel):
respx_mock.get("/foo").mock(return_value=httpx.Response(200, text="my-custom-format"))
- strict_client = Brainbase(base_url=base_url, bearer_token=bearer_token, _strict_response_validation=True)
+ strict_client = Brainbase(base_url=base_url, api_key=api_key, _strict_response_validation=True)
with pytest.raises(APIResponseValidationError):
strict_client.get("/foo", cast_to=Model)
- client = Brainbase(base_url=base_url, bearer_token=bearer_token, _strict_response_validation=False)
+ client = Brainbase(base_url=base_url, api_key=api_key, _strict_response_validation=False)
response = client.get("/foo", cast_to=Model)
assert isinstance(response, str) # type: ignore[unreachable]
@@ -730,7 +702,7 @@ class Model(BaseModel):
)
@mock.patch("time.time", mock.MagicMock(return_value=1696004797))
def test_parse_retry_after_header(self, remaining_retries: int, retry_after: str, timeout: float) -> None:
- client = Brainbase(base_url=base_url, bearer_token=bearer_token, _strict_response_validation=True)
+ client = Brainbase(base_url=base_url, api_key=api_key, _strict_response_validation=True)
headers = httpx.Headers({"retry-after": retry_after})
options = FinalRequestOptions(method="get", url="/foo", max_retries=3)
@@ -840,7 +812,7 @@ def retry_handler(_request: httpx.Request) -> httpx.Response:
class TestAsyncBrainbase:
- client = AsyncBrainbase(base_url=base_url, bearer_token=bearer_token, _strict_response_validation=True)
+ client = AsyncBrainbase(base_url=base_url, api_key=api_key, _strict_response_validation=True)
@pytest.mark.respx(base_url=base_url)
@pytest.mark.asyncio
@@ -868,9 +840,9 @@ def test_copy(self) -> None:
copied = self.client.copy()
assert id(copied) != id(self.client)
- copied = self.client.copy(bearer_token="another My Bearer Token")
- assert copied.bearer_token == "another My Bearer Token"
- assert self.client.bearer_token == "My Bearer Token"
+ copied = self.client.copy(api_key="another My API Key")
+ assert copied.api_key == "another My API Key"
+ assert self.client.api_key == "My API Key"
def test_copy_default_options(self) -> None:
# options that have a default are overridden correctly
@@ -890,10 +862,7 @@ def test_copy_default_options(self) -> None:
def test_copy_default_headers(self) -> None:
client = AsyncBrainbase(
- base_url=base_url,
- bearer_token=bearer_token,
- _strict_response_validation=True,
- default_headers={"X-Foo": "bar"},
+ base_url=base_url, api_key=api_key, _strict_response_validation=True, default_headers={"X-Foo": "bar"}
)
assert client.default_headers["X-Foo"] == "bar"
@@ -927,7 +896,7 @@ def test_copy_default_headers(self) -> None:
def test_copy_default_query(self) -> None:
client = AsyncBrainbase(
- base_url=base_url, bearer_token=bearer_token, _strict_response_validation=True, default_query={"foo": "bar"}
+ base_url=base_url, api_key=api_key, _strict_response_validation=True, default_query={"foo": "bar"}
)
assert _get_params(client)["foo"] == "bar"
@@ -1052,7 +1021,7 @@ async def test_request_timeout(self) -> None:
async def test_client_timeout_option(self) -> None:
client = AsyncBrainbase(
- base_url=base_url, bearer_token=bearer_token, _strict_response_validation=True, timeout=httpx.Timeout(0)
+ base_url=base_url, api_key=api_key, _strict_response_validation=True, timeout=httpx.Timeout(0)
)
request = client._build_request(FinalRequestOptions(method="get", url="/foo"))
@@ -1063,7 +1032,7 @@ async def test_http_client_timeout_option(self) -> None:
# custom timeout given to the httpx client should be used
async with httpx.AsyncClient(timeout=None) as http_client:
client = AsyncBrainbase(
- base_url=base_url, bearer_token=bearer_token, _strict_response_validation=True, http_client=http_client
+ base_url=base_url, api_key=api_key, _strict_response_validation=True, http_client=http_client
)
request = client._build_request(FinalRequestOptions(method="get", url="/foo"))
@@ -1073,7 +1042,7 @@ async def test_http_client_timeout_option(self) -> None:
# no timeout given to the httpx client should not use the httpx default
async with httpx.AsyncClient() as http_client:
client = AsyncBrainbase(
- base_url=base_url, bearer_token=bearer_token, _strict_response_validation=True, http_client=http_client
+ base_url=base_url, api_key=api_key, _strict_response_validation=True, http_client=http_client
)
request = client._build_request(FinalRequestOptions(method="get", url="/foo"))
@@ -1083,7 +1052,7 @@ async def test_http_client_timeout_option(self) -> None:
# explicitly passing the default timeout currently results in it being ignored
async with httpx.AsyncClient(timeout=HTTPX_DEFAULT_TIMEOUT) as http_client:
client = AsyncBrainbase(
- base_url=base_url, bearer_token=bearer_token, _strict_response_validation=True, http_client=http_client
+ base_url=base_url, api_key=api_key, _strict_response_validation=True, http_client=http_client
)
request = client._build_request(FinalRequestOptions(method="get", url="/foo"))
@@ -1095,17 +1064,14 @@ def test_invalid_http_client(self) -> None:
with httpx.Client() as http_client:
AsyncBrainbase(
base_url=base_url,
- bearer_token=bearer_token,
+ api_key=api_key,
_strict_response_validation=True,
http_client=cast(Any, http_client),
)
def test_default_headers_option(self) -> None:
client = AsyncBrainbase(
- base_url=base_url,
- bearer_token=bearer_token,
- _strict_response_validation=True,
- default_headers={"X-Foo": "bar"},
+ base_url=base_url, api_key=api_key, _strict_response_validation=True, default_headers={"X-Foo": "bar"}
)
request = client._build_request(FinalRequestOptions(method="get", url="/foo"))
assert request.headers.get("x-foo") == "bar"
@@ -1113,7 +1079,7 @@ def test_default_headers_option(self) -> None:
client2 = AsyncBrainbase(
base_url=base_url,
- bearer_token=bearer_token,
+ api_key=api_key,
_strict_response_validation=True,
default_headers={
"X-Foo": "stainless",
@@ -1125,21 +1091,18 @@ def test_default_headers_option(self) -> None:
assert request.headers.get("x-stainless-lang") == "my-overriding-header"
def test_validate_headers(self) -> None:
- client = AsyncBrainbase(base_url=base_url, bearer_token=bearer_token, _strict_response_validation=True)
+ client = AsyncBrainbase(base_url=base_url, api_key=api_key, _strict_response_validation=True)
request = client._build_request(FinalRequestOptions(method="get", url="/foo"))
- assert request.headers.get("Authorization") == f"Bearer {bearer_token}"
+ assert request.headers.get("x-api-key") == api_key
with pytest.raises(BrainbaseError):
- with update_env(**{"BEARER_TOKEN": Omit()}):
- client2 = AsyncBrainbase(base_url=base_url, bearer_token=None, _strict_response_validation=True)
+ with update_env(**{"API_KEY": Omit()}):
+ client2 = AsyncBrainbase(base_url=base_url, api_key=None, _strict_response_validation=True)
_ = client2
def test_default_query_option(self) -> None:
client = AsyncBrainbase(
- base_url=base_url,
- bearer_token=bearer_token,
- _strict_response_validation=True,
- default_query={"query_param": "bar"},
+ base_url=base_url, api_key=api_key, _strict_response_validation=True, default_query={"query_param": "bar"}
)
request = client._build_request(FinalRequestOptions(method="get", url="/foo"))
url = httpx.URL(request.url)
@@ -1340,7 +1303,7 @@ class Model(BaseModel):
def test_base_url_setter(self) -> None:
client = AsyncBrainbase(
- base_url="https://example.com/from_init", bearer_token=bearer_token, _strict_response_validation=True
+ base_url="https://example.com/from_init", api_key=api_key, _strict_response_validation=True
)
assert client.base_url == "https://example.com/from_init/"
@@ -1350,20 +1313,18 @@ def test_base_url_setter(self) -> None:
def test_base_url_env(self) -> None:
with update_env(BRAINBASE_BASE_URL="http://localhost:5000/from/env"):
- client = AsyncBrainbase(bearer_token=bearer_token, _strict_response_validation=True)
+ client = AsyncBrainbase(api_key=api_key, _strict_response_validation=True)
assert client.base_url == "http://localhost:5000/from/env/"
@pytest.mark.parametrize(
"client",
[
AsyncBrainbase(
- base_url="http://localhost:5000/custom/path/",
- bearer_token=bearer_token,
- _strict_response_validation=True,
+ base_url="http://localhost:5000/custom/path/", api_key=api_key, _strict_response_validation=True
),
AsyncBrainbase(
base_url="http://localhost:5000/custom/path/",
- bearer_token=bearer_token,
+ api_key=api_key,
_strict_response_validation=True,
http_client=httpx.AsyncClient(),
),
@@ -1384,13 +1345,11 @@ def test_base_url_trailing_slash(self, client: AsyncBrainbase) -> None:
"client",
[
AsyncBrainbase(
- base_url="http://localhost:5000/custom/path/",
- bearer_token=bearer_token,
- _strict_response_validation=True,
+ base_url="http://localhost:5000/custom/path/", api_key=api_key, _strict_response_validation=True
),
AsyncBrainbase(
base_url="http://localhost:5000/custom/path/",
- bearer_token=bearer_token,
+ api_key=api_key,
_strict_response_validation=True,
http_client=httpx.AsyncClient(),
),
@@ -1411,13 +1370,11 @@ def test_base_url_no_trailing_slash(self, client: AsyncBrainbase) -> None:
"client",
[
AsyncBrainbase(
- base_url="http://localhost:5000/custom/path/",
- bearer_token=bearer_token,
- _strict_response_validation=True,
+ base_url="http://localhost:5000/custom/path/", api_key=api_key, _strict_response_validation=True
),
AsyncBrainbase(
base_url="http://localhost:5000/custom/path/",
- bearer_token=bearer_token,
+ api_key=api_key,
_strict_response_validation=True,
http_client=httpx.AsyncClient(),
),
@@ -1435,7 +1392,7 @@ def test_absolute_request_url(self, client: AsyncBrainbase) -> None:
assert request.url == "https://myapi.com/foo"
async def test_copied_client_does_not_close_http(self) -> None:
- client = AsyncBrainbase(base_url=base_url, bearer_token=bearer_token, _strict_response_validation=True)
+ client = AsyncBrainbase(base_url=base_url, api_key=api_key, _strict_response_validation=True)
assert not client.is_closed()
copied = client.copy()
@@ -1447,7 +1404,7 @@ async def test_copied_client_does_not_close_http(self) -> None:
assert not client.is_closed()
async def test_client_context_manager(self) -> None:
- client = AsyncBrainbase(base_url=base_url, bearer_token=bearer_token, _strict_response_validation=True)
+ client = AsyncBrainbase(base_url=base_url, api_key=api_key, _strict_response_validation=True)
async with client as c2:
assert c2 is client
assert not c2.is_closed()
@@ -1470,10 +1427,7 @@ class Model(BaseModel):
async def test_client_max_retries_validation(self) -> None:
with pytest.raises(TypeError, match=r"max_retries cannot be None"):
AsyncBrainbase(
- base_url=base_url,
- bearer_token=bearer_token,
- _strict_response_validation=True,
- max_retries=cast(Any, None),
+ base_url=base_url, api_key=api_key, _strict_response_validation=True, max_retries=cast(Any, None)
)
@pytest.mark.respx(base_url=base_url)
@@ -1484,12 +1438,12 @@ class Model(BaseModel):
respx_mock.get("/foo").mock(return_value=httpx.Response(200, text="my-custom-format"))
- strict_client = AsyncBrainbase(base_url=base_url, bearer_token=bearer_token, _strict_response_validation=True)
+ strict_client = AsyncBrainbase(base_url=base_url, api_key=api_key, _strict_response_validation=True)
with pytest.raises(APIResponseValidationError):
await strict_client.get("/foo", cast_to=Model)
- client = AsyncBrainbase(base_url=base_url, bearer_token=bearer_token, _strict_response_validation=False)
+ client = AsyncBrainbase(base_url=base_url, api_key=api_key, _strict_response_validation=False)
response = await client.get("/foo", cast_to=Model)
assert isinstance(response, str) # type: ignore[unreachable]
@@ -1518,7 +1472,7 @@ class Model(BaseModel):
@mock.patch("time.time", mock.MagicMock(return_value=1696004797))
@pytest.mark.asyncio
async def test_parse_retry_after_header(self, remaining_retries: int, retry_after: str, timeout: float) -> None:
- client = AsyncBrainbase(base_url=base_url, bearer_token=bearer_token, _strict_response_validation=True)
+ client = AsyncBrainbase(base_url=base_url, api_key=api_key, _strict_response_validation=True)
headers = httpx.Headers({"retry-after": retry_after})
options = FinalRequestOptions(method="get", url="/foo", max_retries=3)