@@ -238,48 +238,56 @@ def test_connect_with_links(self):
238238
239239    @requires_api_version ('1.22' ) 
240240    def  test_connect_with_ipv4_address (self ):
241-         net_name , net_id  =  self .create_network ()
241+         net_name , net_id  =  self .create_network (
242+             ipam = create_ipam_config (
243+                 driver = 'default' ,
244+                 pool_configs = [
245+                     create_ipam_pool (
246+                         subnet = "172.28.0.0/16" , iprange = "172.28.5.0/24" ,
247+                         gateway = "172.28.5.254" 
248+                     )
249+                 ]
250+             )
251+         )
242252
243253        container  =  self .create_and_start (
244254            host_config = self .client .create_host_config (network_mode = net_name ))
245255
246256        self .client .disconnect_container_from_network (container , net_name )
247257        self .client .connect_container_to_network (
248-             container , net_name ,
249-              ipv4_address = '192.168.0.1' )
258+             container , net_name ,  ipv4_address = '172.28.5.24' 
259+         )
250260
251261        container_data  =  self .client .inspect_container (container )
262+         net_data  =  container_data ['NetworkSettings' ]['Networks' ][net_name ]
252263        self .assertEqual (
253-             container_data ['NetworkSettings' ]['Networks' ][net_name ]
254-                           ['IPAMConfig' ]['IPv4Address' ],
255-             '192.168.0.1' )
256- 
257-         self .create_and_start (
258-             name = 'docker-py-test-upstream' ,
259-             host_config = self .client .create_host_config (network_mode = net_name ))
260- 
261-         self .execute (container , ['nslookup' , 'bar' ])
264+             net_data ['IPAMConfig' ]['IPv4Address' ], '172.28.5.24' 
265+         )
262266
263267    @requires_api_version ('1.22' ) 
264268    def  test_connect_with_ipv6_address (self ):
265-         net_name , net_id  =  self .create_network ()
269+         net_name , net_id  =  self .create_network (
270+             ipam = create_ipam_config (
271+                 driver = 'default' ,
272+                 pool_configs = [
273+                     create_ipam_pool (
274+                         subnet = "2001:389::1/64" , iprange = "2001:389::0/96" ,
275+                         gateway = "2001:389::ffff" 
276+                     )
277+                 ]
278+             )
279+         )
266280
267281        container  =  self .create_and_start (
268282            host_config = self .client .create_host_config (network_mode = net_name ))
269283
270284        self .client .disconnect_container_from_network (container , net_name )
271285        self .client .connect_container_to_network (
272-             container , net_name ,
273-              ipv6_address = '2001:389::1' )
286+             container , net_name ,  ipv6_address = '2001:389::f00d' 
287+         )
274288
275289        container_data  =  self .client .inspect_container (container )
290+         net_data  =  container_data ['NetworkSettings' ]['Networks' ][net_name ]
276291        self .assertEqual (
277-             container_data ['NetworkSettings' ]['Networks' ][net_name ]
278-                           ['IPAMConfig' ]['IPv6Address' ],
279-             '2001:389::1' )
280- 
281-         self .create_and_start (
282-             name = 'docker-py-test-upstream' ,
283-             host_config = self .client .create_host_config (network_mode = net_name ))
284- 
285-         self .execute (container , ['nslookup' , 'bar' ])
292+             net_data ['IPAMConfig' ]['IPv6Address' ], '2001:389::f00d' 
293+         )
0 commit comments