Skip to content

Commit d6ba6f2

Browse files
Add environment base URL normalization and validation tests
Co-authored-by: Shri Sukhani <shrisukhani@users.noreply.github.com>
1 parent e11e3a1 commit d6ba6f2

1 file changed

Lines changed: 17 additions & 0 deletions

File tree

‎tests/test_config.py‎

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,23 @@ def test_client_config_from_env_reads_api_key_and_base_url(monkeypatch):
2828
assert config.base_url == "https://example.local"
2929

3030

31+
def test_client_config_from_env_normalizes_base_url(monkeypatch):
32+
monkeypatch.setenv("HYPERBROWSER_API_KEY", "test-key")
33+
monkeypatch.setenv("HYPERBROWSER_BASE_URL", " https://example.local/ ")
34+
35+
config = ClientConfig.from_env()
36+
37+
assert config.base_url == "https://example.local"
38+
39+
40+
def test_client_config_from_env_rejects_invalid_base_url(monkeypatch):
41+
monkeypatch.setenv("HYPERBROWSER_API_KEY", "test-key")
42+
monkeypatch.setenv("HYPERBROWSER_BASE_URL", "example.local")
43+
44+
with pytest.raises(HyperbrowserError, match="base_url must start with"):
45+
ClientConfig.from_env()
46+
47+
3148
def test_client_config_normalizes_whitespace_and_trailing_slash():
3249
config = ClientConfig(api_key=" test-key ", base_url=" https://example.local/ ")
3350

0 commit comments

Comments
 (0)