MCPcopy Create free account
hub / github.com/anomalyco/opencode-sdk-python / test_copy_default_headers

Method test_copy_default_headers

tests/test_client.py:104–134  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

102 assert isinstance(self.client.timeout, httpx.Timeout)
103
104 def test_copy_default_headers(self) -> None:
105 client = Opencode(base_url=base_url, _strict_response_validation=True, default_headers={"X-Foo": "bar"})
106 assert client.default_headers["X-Foo"] == "bar"
107
108 # does not override the already given value when not specified
109 copied = client.copy()
110 assert copied.default_headers["X-Foo"] == "bar"
111
112 # merges already given headers
113 copied = client.copy(default_headers={"X-Bar": "stainless"})
114 assert copied.default_headers["X-Foo"] == "bar"
115 assert copied.default_headers["X-Bar"] == "stainless"
116
117 # uses new values for any already given headers
118 copied = client.copy(default_headers={"X-Foo": "stainless"})
119 assert copied.default_headers["X-Foo"] == "stainless"
120
121 # set_default_headers
122
123 # completely overrides already set values
124 copied = client.copy(set_default_headers={})
125 assert copied.default_headers.get("X-Foo") is None
126
127 copied = client.copy(set_default_headers={"X-Bar": "Robert"})
128 assert copied.default_headers["X-Bar"] == "Robert"
129
130 with pytest.raises(
131 ValueError,
132 match="`default_headers` and `set_default_headers` arguments are mutually exclusive",
133 ):
134 client.copy(set_default_headers={}, default_headers={"X-Foo": "Bar"})
135
136 def test_copy_default_query(self) -> None:
137 client = Opencode(base_url=base_url, _strict_response_validation=True, default_query={"foo": "bar"})

Callers

nothing calls this directly

Calls 3

copyMethod · 0.95
OpencodeClass · 0.90
getMethod · 0.45

Tested by

no test coverage detected