Skip to content

Commit f495225

Browse files
chore(internal): test updates (#335)
1 parent c2cf1c4 commit f495225

File tree

3 files changed

+13
-6
lines changed

3 files changed

+13
-6
lines changed

src/orb/_utils/_reflection.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ def assert_signatures_in_sync(
3434

3535
if custom_param.annotation != source_param.annotation:
3636
errors.append(
37-
f"types for the `{name}` param are do not match; source={repr(source_param.annotation)} checking={repr(source_param.annotation)}"
37+
f"types for the `{name}` param are do not match; source={repr(source_param.annotation)} checking={repr(custom_param.annotation)}"
3838
)
3939
continue
4040

tests/test_client.py

+5-2
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
from pydantic import ValidationError
1818

1919
from orb import Orb, AsyncOrb, APIResponseValidationError
20+
from orb._types import Omit
2021
from orb._models import BaseModel, FinalRequestOptions
2122
from orb._constants import RAW_RESPONSE_HEADER
2223
from orb._exceptions import OrbError, APIStatusError, APITimeoutError, APIResponseValidationError
@@ -319,7 +320,8 @@ def test_validate_headers(self) -> None:
319320
assert request.headers.get("Authorization") == f"Bearer {api_key}"
320321

321322
with pytest.raises(OrbError):
322-
client2 = Orb(base_url=base_url, api_key=None, _strict_response_validation=True)
323+
with update_env(**{"ORB_API_KEY": Omit()}):
324+
client2 = Orb(base_url=base_url, api_key=None, _strict_response_validation=True)
323325
_ = client2
324326

325327
def test_default_query_option(self) -> None:
@@ -1076,7 +1078,8 @@ def test_validate_headers(self) -> None:
10761078
assert request.headers.get("Authorization") == f"Bearer {api_key}"
10771079

10781080
with pytest.raises(OrbError):
1079-
client2 = AsyncOrb(base_url=base_url, api_key=None, _strict_response_validation=True)
1081+
with update_env(**{"ORB_API_KEY": Omit()}):
1082+
client2 = AsyncOrb(base_url=base_url, api_key=None, _strict_response_validation=True)
10801083
_ = client2
10811084

10821085
def test_default_query_option(self) -> None:

tests/utils.py

+7-3
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
from datetime import date, datetime
99
from typing_extensions import Literal, get_args, get_origin, assert_type
1010

11-
from orb._types import NoneType
11+
from orb._types import Omit, NoneType
1212
from orb._utils import (
1313
is_dict,
1414
is_list,
@@ -139,11 +139,15 @@ def _assert_list_type(type_: type[object], value: object) -> None:
139139

140140

141141
@contextlib.contextmanager
142-
def update_env(**new_env: str) -> Iterator[None]:
142+
def update_env(**new_env: str | Omit) -> Iterator[None]:
143143
old = os.environ.copy()
144144

145145
try:
146-
os.environ.update(new_env)
146+
for name, value in new_env.items():
147+
if isinstance(value, Omit):
148+
os.environ.pop(name, None)
149+
else:
150+
os.environ[name] = value
147151

148152
yield None
149153
finally:

0 commit comments

Comments
 (0)