@@ -83,13 +83,21 @@ def test_raises_http_errors_as_exceptions(self, post_mock):
8383 @patch ("python_graphql_client.graphql_client.requests.post" )
8484 def test_execute_query_with_headers (self , post_mock ):
8585 """Sends a graphql POST request with headers."""
86- headers = {"Content-Type" : "application/json" }
87- client = GraphqlClient (endpoint = "http://www.test-api.com/" , headers = headers )
86+ client = GraphqlClient (
87+ endpoint = "http://www.test-api.com/" ,
88+ headers = {"Content-Type" : "application/json" , "Existing" : "123" ,},
89+ )
8890 query = ""
89- client .execute (query )
91+ client .execute (query = query , headers = { "Existing" : "123" , "New" : "foo" } )
9092
9193 post_mock .assert_called_once_with (
92- "http://www.test-api.com/" , json = {"query" : query }, headers = headers
94+ "http://www.test-api.com/" ,
95+ json = {"query" : query },
96+ headers = {
97+ "Content-Type" : "application/json" ,
98+ "Existing" : "123" ,
99+ "New" : "foo" ,
100+ },
93101 )
94102
95103 @patch ("python_graphql_client.graphql_client.requests.post" )
@@ -176,14 +184,22 @@ async def test_execute_query_with_variables(self, mock_post):
176184 async def test_execute_query_with_headers (self , mock_post ):
177185 """Sends a graphql POST request with headers."""
178186 mock_post .return_value .__aenter__ .return_value .json = CoroutineMock ()
179- headers = {"Content-Type" : "application/json" }
180- client = GraphqlClient (endpoint = "http://www.test-api.com/" , headers = headers )
187+ client = GraphqlClient (
188+ endpoint = "http://www.test-api.com/" ,
189+ headers = {"Content-Type" : "application/json" , "Existing" : "123" ,},
190+ )
181191 query = ""
182192
183- await client .execute_async (query )
193+ await client .execute_async ("" , headers = { "Existing" : "123" , "New" : "foo" } )
184194
185195 mock_post .assert_called_once_with (
186- "http://www.test-api.com/" , json = {"query" : query }, headers = headers
196+ "http://www.test-api.com/" ,
197+ json = {"query" : query },
198+ headers = {
199+ "Content-Type" : "application/json" ,
200+ "Existing" : "123" ,
201+ "New" : "foo" ,
202+ },
187203 )
188204
189205 @unittest_run_loop
0 commit comments