Skip to content

Commit

Permalink
✅ test(utils): more coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
ljnsn committed Oct 12, 2024
1 parent ba3bfc4 commit 708a722
Showing 1 changed file with 37 additions and 0 deletions.
37 changes: 37 additions & 0 deletions tests/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,8 @@ class Security(msgspec.Struct):
},
),
]
field_with_no_meta: str = "test"
none_field: str | None = None

security = Security(api_key="test_key")
client = utils.configure_security_client(None, security)
Expand Down Expand Up @@ -143,6 +145,41 @@ class Security(msgspec.Struct):
client = utils.configure_security_client(None, security)
assert client.headers == {"Authorization": "Bearer test_token"}

def test_configure_security_client_with_option(self) -> None:
"""Test configuring security client with security option."""

class SecurityOption(msgspec.Struct):
api_key: Annotated[
str,
msgspec.Meta(
extra={
"security": {
"scheme": True,
"type": "apiKey",
"sub_type": "header",
"field_name": "X-API-Key",
},
},
),
]
other_field: str = "test"

class Security(msgspec.Struct):
option: Annotated[
SecurityOption,
msgspec.Meta(
extra={
"security": {
"option": True,
},
},
),
]

security = Security(option=SecurityOption(api_key="test_option_key"))
client = utils.configure_security_client(None, security)
assert client.headers == {"X-API-Key": "test_option_key"}


class TestPathParamHandlers:
"""Tests for path param handlers."""
Expand Down

0 comments on commit 708a722

Please sign in to comment.