@@ -46,10 +46,11 @@ def getheaders(self):
4646
4747
4848class DummyConnection (object ):
49- def __init__ (self , host , port ):
49+ def __init__ (self , host , port , secure = False ):
5050 self .host = host
5151 self .port = port
5252 self .response = DummyResponse ({'content-type' : 'application/json' })
53+ self .secure = secure
5354
5455 def request (self , method , path , body , headers ):
5556 return method , path , body , headers
@@ -177,27 +178,33 @@ def test_set_request_data(args, expected):
177178@pytest .mark .parametrize (('args' , 'expected' ), [
178179 (DummyNamespace ({'_url' : '' }),
179180 {'query' : None , 'host' : 'localhost' , 'fragment' : None ,
180- 'port' : 443 , 'netloc' : None , 'scheme' : 'https' , 'path' : '/' }),
181+ 'port' : 443 , 'netloc' : None , 'scheme' : 'https' , 'path' : '/' ,
182+ 'secure' : True }),
181183 (DummyNamespace ({'_url' : 'example.com' }),
182- {'host' : 'example.com' , 'port' : 443 , 'path' : '/' }),
184+ {'host' : 'example.com' , 'port' : 443 , 'path' : '/' , 'secure' : True }),
183185 (DummyNamespace ({'_url' : 'example.com/httpbin/get' }),
184- {'host' : 'example.com' , 'port' : 443 , 'path' : '/httpbin/get' }),
186+ {'host' : 'example.com' , 'port' : 443 , 'path' : '/httpbin/get' ,
187+ 'secure' : True }),
185188 (DummyNamespace ({'_url' : 'example.com:80' }),
186- {'host' : 'example.com' , 'port' : 80 , 'path' : '/' }),
189+ {'host' : 'example.com' , 'port' : 80 , 'path' : '/' , 'secure' : True }),
187190 (DummyNamespace ({'_url' : 'http://example.com' }),
188- {'host' : 'example.com' , 'port' : 80 , 'path' : '/' , 'scheme' : 'http' }),
191+ {'host' : 'example.com' , 'port' : 80 , 'path' : '/' , 'scheme' : 'http' ,
192+ 'secure' : False }),
189193 (DummyNamespace ({'_url' : 'http://example.com/' }),
190- {'host' : 'example.com' , 'port' : 80 , 'path' : '/' , 'scheme' : 'http' }),
194+ {'host' : 'example.com' , 'port' : 80 , 'path' : '/' , 'scheme' : 'http' ,
195+ 'secure' : False }),
191196 (DummyNamespace ({'_url' : 'http://example.com:8080' }),
192- {'host' : 'example.com' , 'port' : 8080 , 'path' : '/' , 'scheme' : 'http' }),
197+ {'host' : 'example.com' , 'port' : 8080 , 'path' : '/' , 'scheme' : 'http' ,
198+ 'secure' : False }),
193199 (DummyNamespace ({'_url' : 'https://example.com' }),
194- {'host' : 'example.com' , 'port' : 443 , 'path' : '/' , 'scheme' : 'https' }),
200+ {'host' : 'example.com' , 'port' : 443 , 'path' : '/' , 'scheme' : 'https' ,
201+ 'secure' : True }),
195202 (DummyNamespace ({'_url' : 'https://example.com/httpbin/get' }),
196203 {'host' : 'example.com' , 'port' : 443 , 'path' : '/httpbin/get' ,
197- 'scheme' : 'https' }),
204+ 'scheme' : 'https' , 'secure' : True }),
198205 (DummyNamespace ({'_url' : 'https://example.com:8443/httpbin/get' }),
199206 {'host' : 'example.com' , 'port' : 8443 , 'path' : '/httpbin/get' ,
200- 'scheme' : 'https' }),
207+ 'scheme' : 'https' , 'secure' : True }),
201208], ids = [
202209 'set no url (it means default settings)' ,
203210 'set only hostname' ,
0 commit comments