Skip to content

Commit c39280d

Browse files
Expand env-header parser coverage in config tests
Co-authored-by: Shri Sukhani <shrisukhani@users.noreply.github.com>
1 parent d6ed744 commit c39280d

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

tests/test_config.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,22 @@ def test_client_config_from_env_rejects_newline_header_values(monkeypatch):
9191
ClientConfig.from_env()
9292

9393

94+
def test_client_config_from_env_rejects_duplicate_header_names_after_normalization(
95+
monkeypatch,
96+
):
97+
monkeypatch.setenv("HYPERBROWSER_API_KEY", "test-key")
98+
monkeypatch.setenv(
99+
"HYPERBROWSER_HEADERS",
100+
'{"X-Correlation-Id":"one"," X-Correlation-Id ":"two"}',
101+
)
102+
103+
with pytest.raises(
104+
HyperbrowserError,
105+
match="duplicate header names are not allowed after normalization",
106+
):
107+
ClientConfig.from_env()
108+
109+
94110
def test_client_config_from_env_ignores_blank_headers(monkeypatch):
95111
monkeypatch.setenv("HYPERBROWSER_API_KEY", "test-key")
96112
monkeypatch.setenv("HYPERBROWSER_HEADERS", " ")
@@ -216,3 +232,10 @@ def test_client_config_accepts_mapping_header_inputs():
216232
config = ClientConfig(api_key="test-key", headers=headers)
217233

218234
assert config.headers == {"X-Correlation-Id": "abc123"}
235+
236+
237+
def test_client_config_parse_headers_from_env_rejects_non_string_input():
238+
with pytest.raises(
239+
HyperbrowserError, match="HYPERBROWSER_HEADERS must be a string"
240+
):
241+
ClientConfig.parse_headers_from_env(123) # type: ignore[arg-type]

0 commit comments

Comments
 (0)