44
55import pytest
66
7- from devhelm ._errors import DevhelmError
87from devhelm ._http import DevhelmConfig , build_client , path_param , unwrap_single
98
109
@@ -41,18 +40,14 @@ def test_encodes_special_chars(self) -> None:
4140
4241
4342class TestBuildClient :
44- def test_requires_org_id (self , monkeypatch : pytest .MonkeyPatch ) -> None :
43+ def test_defaults_org_and_workspace (self , monkeypatch : pytest .MonkeyPatch ) -> None :
4544 monkeypatch .delenv ("DEVHELM_ORG_ID" , raising = False )
4645 monkeypatch .delenv ("DEVHELM_WORKSPACE_ID" , raising = False )
4746 config = DevhelmConfig (token = "test-token" )
48- with pytest .raises (DevhelmError , match = "org_id is required" ):
49- build_client (config )
50-
51- def test_requires_workspace_id (self , monkeypatch : pytest .MonkeyPatch ) -> None :
52- monkeypatch .delenv ("DEVHELM_WORKSPACE_ID" , raising = False )
53- config = DevhelmConfig (token = "test-token" , org_id = "1" )
54- with pytest .raises (DevhelmError , match = "workspace_id is required" ):
55- build_client (config )
47+ client = build_client (config )
48+ assert client .headers ["x-phelm-org-id" ] == "1"
49+ assert client .headers ["x-phelm-workspace-id" ] == "1"
50+ client .close ()
5651
5752 def test_reads_from_env (self , monkeypatch : pytest .MonkeyPatch ) -> None :
5853 monkeypatch .setenv ("DEVHELM_ORG_ID" , "42" )
@@ -72,9 +67,7 @@ def test_config_overrides_env(self, monkeypatch: pytest.MonkeyPatch) -> None:
7267 assert client .headers ["x-phelm-workspace-id" ] == "cfg-ws"
7368 client .close ()
7469
75- def test_strips_trailing_slash (self , monkeypatch : pytest .MonkeyPatch ) -> None :
76- monkeypatch .setenv ("DEVHELM_ORG_ID" , "1" )
77- monkeypatch .setenv ("DEVHELM_WORKSPACE_ID" , "1" )
70+ def test_strips_trailing_slash (self ) -> None :
7871 config = DevhelmConfig (token = "t" , base_url = "https://api.example.com///" )
7972 client = build_client (config )
8073 assert str (client .base_url ) == "https://api.example.com"
0 commit comments