File tree Expand file tree Collapse file tree 2 files changed +16
-9
lines changed Expand file tree Collapse file tree 2 files changed +16
-9
lines changed Original file line number Diff line number Diff line change @@ -281,18 +281,18 @@ def timeouts(self, options):
281281 params )
282282 return r .status_code
283283
284- def remap_hosts (self , hostmap ):
284+ def remap_hosts (self , address = None , ip_address = None , hostmap = {} ):
285285 """
286286 Remap the hosts for a specific URL
287287
288- :param hostmap: A dictionary of url/ip_address pairs to remap
288+ :param address: url that you wish to remap
289+ :param ip_address: IP Address that will handle all traffic for the address passed in
290+ :param **hostmap: Other hosts to be added as keyword arguments
289291 """
290- if not isinstance (hostmap , dict ):
291- raise TypeError ("hostmap needs to be a dictionary" )
292-
293- if not hostmap :
294- raise Exception ("hostmap should have at least one entry" )
295-
292+
293+ if (address is not None and ip_address is not None ):
294+ hostmap [address ] = ip_address
295+
296296 r = requests .post ('%s/proxy/%s/hosts' % (self .host , self .port ),
297297 json .dumps (hostmap ),
298298 headers = {'content-type' : 'application/json' })
Original file line number Diff line number Diff line change @@ -225,7 +225,14 @@ def test_remap_hosts(self):
225225 """
226226 /proxy/:port/hosts
227227 """
228- status_code = self .client .remap_hosts ({"example.com" : "1.2.3.4" })
228+ status_code = self .client .remap_hosts ("example.com" , "1.2.3.4" )
229+ assert (status_code == 200 )
230+
231+ def test_remap_hosts_with_hostmap (self ):
232+ """
233+ /proxy/:port/hosts
234+ """
235+ status_code = self .client .remap_hosts (hostmap = {"example.com" : "1.2.3.4" })
229236 assert (status_code == 200 )
230237
231238 def test_wait_for_traffic_to_stop (self ):
You can’t perform that action at this time.
0 commit comments