mirror of
https://github.com/thinking-machines-lab/tinker.git
synced 2026-05-01 17:45:18 +00:00
Sync contents
This commit is contained in:
parent
5ad4282c96
commit
e7a0d0ca2d
15 changed files with 91 additions and 31 deletions
|
|
@ -35,7 +35,7 @@ from tinker._base_client import (
|
|||
from .utils import update_env
|
||||
|
||||
base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010")
|
||||
api_key = "My API Key"
|
||||
api_key = "tml-My API Key"
|
||||
|
||||
|
||||
def _get_params(client: BaseClient[Any, Any]) -> dict[str, str]:
|
||||
|
|
@ -97,9 +97,9 @@ class TestTinker:
|
|||
copied = self.client.copy()
|
||||
assert id(copied) != id(self.client)
|
||||
|
||||
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"
|
||||
copied = self.client.copy(api_key="tml-another My API Key")
|
||||
assert copied.api_key == "tml-another My API Key"
|
||||
assert self.client.api_key == "tml-My API Key"
|
||||
|
||||
def test_copy_default_options(self) -> None:
|
||||
# options that have a default are overridden correctly
|
||||
|
|
@ -353,6 +353,10 @@ class TestTinker:
|
|||
client2 = Tinker(base_url=base_url, api_key=None, _strict_response_validation=True)
|
||||
_ = client2
|
||||
|
||||
def test_api_key_prefix_validation(self) -> None:
|
||||
with pytest.raises(TinkerError):
|
||||
Tinker(base_url=base_url, api_key="not-tml-prefix", _strict_response_validation=True)
|
||||
|
||||
def test_default_query_option(self) -> None:
|
||||
client = Tinker(
|
||||
base_url=base_url, api_key=api_key, _strict_response_validation=True, default_query={"query_param": "bar"}
|
||||
|
|
@ -1076,9 +1080,9 @@ class TestAsyncTinker:
|
|||
copied = self.client.copy()
|
||||
assert id(copied) != id(self.client)
|
||||
|
||||
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"
|
||||
copied = self.client.copy(api_key="tml-another My API Key")
|
||||
assert copied.api_key == "tml-another My API Key"
|
||||
assert self.client.api_key == "tml-My API Key"
|
||||
|
||||
def test_copy_default_options(self) -> None:
|
||||
# options that have a default are overridden correctly
|
||||
|
|
@ -1334,6 +1338,10 @@ class TestAsyncTinker:
|
|||
client2 = AsyncTinker(base_url=base_url, api_key=None, _strict_response_validation=True)
|
||||
_ = client2
|
||||
|
||||
def test_api_key_prefix_validation(self) -> None:
|
||||
with pytest.raises(TinkerError):
|
||||
AsyncTinker(base_url=base_url, api_key="not-tml-prefix", _strict_response_validation=True)
|
||||
|
||||
def test_default_query_option(self) -> None:
|
||||
client = AsyncTinker(
|
||||
base_url=base_url, api_key=api_key, _strict_response_validation=True, default_query={"query_param": "bar"}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue