1+ import pytest
2+ import unittest
3+
14import docker
2- from docker .constants import DEFAULT_DATA_CHUNK_SIZE
5+ from docker .constants import DEFAULT_DATA_CHUNK_SIZE , DEFAULT_DOCKER_API_VERSION
36from docker .models .containers import Container , _create_container_args
47from docker .models .images import Image
5- import unittest
6-
78from .fake_api import FAKE_CONTAINER_ID , FAKE_IMAGE_ID , FAKE_EXEC_ID
89from .fake_api_client import make_fake_client
9- import pytest
1010
1111
1212class ContainerCollectionTest (unittest .TestCase ):
@@ -74,7 +74,7 @@ def test_create_container_args(self):
7474 name = 'somename' ,
7575 network_disabled = False ,
7676 network = 'foo' ,
77- network_driver_opt = {'key1' : 'a' },
77+ network_config = {'aliases' : [ 'test' ], 'driver_opt' : { ' key1' : 'a' } },
7878 oom_kill_disable = True ,
7979 oom_score_adj = 5 ,
8080 pid_mode = 'host' ,
@@ -99,7 +99,7 @@ def test_create_container_args(self):
9999 user = 'bob' ,
100100 userns_mode = 'host' ,
101101 uts_mode = 'host' ,
102- version = '1.23' ,
102+ version = DEFAULT_DOCKER_API_VERSION ,
103103 volume_driver = 'some_driver' ,
104104 volumes = [
105105 '/home/user1/:/mnt/vol2' ,
@@ -189,7 +189,9 @@ def test_create_container_args(self):
189189 mac_address = 'abc123' ,
190190 name = 'somename' ,
191191 network_disabled = False ,
192- networking_config = {'foo' : {'driver_opt' : {'key1' : 'a' }}},
192+ networking_config = {'EndpointsConfig' : {
193+ 'foo' : {'Aliases' : ['test' ], 'DriverOpts' : {'key1' : 'a' }}}
194+ },
193195 platform = 'linux' ,
194196 ports = [('1111' , 'tcp' ), ('2222' , 'tcp' )],
195197 stdin_open = True ,
@@ -346,39 +348,44 @@ def test_run_platform(self):
346348 host_config = {'NetworkMode' : 'default' },
347349 )
348350
349- def test_run_network_driver_opts_without_network (self ):
351+ def test_run_network_config_without_network (self ):
350352 client = make_fake_client ()
351353
352354 with pytest .raises (RuntimeError ):
353355 client .containers .run (
354356 image = 'alpine' ,
355- network_driver_opt = {'key1' : 'a' }
357+ network_config = {'aliases' : ['test' ],
358+ 'driver_opt' : {'key1' : 'a' }}
356359 )
357360
358- def test_run_network_driver_opts_with_network_mode (self ):
361+ def test_run_network_config_with_network_mode (self ):
359362 client = make_fake_client ()
360363
361364 with pytest .raises (RuntimeError ):
362365 client .containers .run (
363366 image = 'alpine' ,
364367 network_mode = 'none' ,
365- network_driver_opt = {'key1' : 'a' }
368+ network_config = {'aliases' : ['test' ],
369+ 'driver_opt' : {'key1' : 'a' }}
366370 )
367371
368- def test_run_network_driver_opts (self ):
372+ def test_run_network_config (self ):
369373 client = make_fake_client ()
370374
371375 client .containers .run (
372376 image = 'alpine' ,
373377 network = 'foo' ,
374- network_driver_opt = {'key1' : 'a' }
378+ network_config = {'aliases' : ['test' ],
379+ 'driver_opt' : {'key1' : 'a' }}
375380 )
376381
377382 client .api .create_container .assert_called_with (
378383 detach = False ,
379384 image = 'alpine' ,
380385 command = None ,
381- networking_config = {'foo' : {'driver_opt' : {'key1' : 'a' }}},
386+ networking_config = {'EndpointsConfig' : {
387+ 'foo' : {'Aliases' : ['test' ], 'DriverOpts' : {'key1' : 'a' }}}
388+ },
382389 host_config = {'NetworkMode' : 'foo' }
383390 )
384391
@@ -409,12 +416,13 @@ def test_create_with_image_object(self):
409416 host_config = {'NetworkMode' : 'default' }
410417 )
411418
412- def test_create_network_driver_opts_without_network (self ):
419+ def test_create_network_config_without_network (self ):
413420 client = make_fake_client ()
414421
415422 client .containers .create (
416423 image = 'alpine' ,
417- network_driver_opt = {'key1' : 'a' }
424+ network_config = {'aliases' : ['test' ],
425+ 'driver_opt' : {'key1' : 'a' }}
418426 )
419427
420428 client .api .create_container .assert_called_with (
@@ -423,13 +431,14 @@ def test_create_network_driver_opts_without_network(self):
423431 host_config = {'NetworkMode' : 'default' }
424432 )
425433
426- def test_create_network_driver_opts_with_network_mode (self ):
434+ def test_create_network_config_with_network_mode (self ):
427435 client = make_fake_client ()
428436
429437 client .containers .create (
430438 image = 'alpine' ,
431439 network_mode = 'none' ,
432- network_driver_opt = {'key1' : 'a' }
440+ network_config = {'aliases' : ['test' ],
441+ 'driver_opt' : {'key1' : 'a' }}
433442 )
434443
435444 client .api .create_container .assert_called_with (
@@ -438,19 +447,22 @@ def test_create_network_driver_opts_with_network_mode(self):
438447 host_config = {'NetworkMode' : 'none' }
439448 )
440449
441- def test_create_network_driver_opts (self ):
450+ def test_create_network_config (self ):
442451 client = make_fake_client ()
443452
444453 client .containers .create (
445454 image = 'alpine' ,
446455 network = 'foo' ,
447- network_driver_opt = {'key1' : 'a' }
456+ network_config = {'aliases' : ['test' ],
457+ 'driver_opt' : {'key1' : 'a' }}
448458 )
449459
450460 client .api .create_container .assert_called_with (
451461 image = 'alpine' ,
452462 command = None ,
453- networking_config = {'foo' : {'driver_opt' : {'key1' : 'a' }}},
463+ networking_config = {'EndpointsConfig' : {
464+ 'foo' : {'Aliases' : ['test' ], 'DriverOpts' : {'key1' : 'a' }}}
465+ },
454466 host_config = {'NetworkMode' : 'foo' }
455467 )
456468
@@ -479,6 +491,7 @@ def test_list(self):
479491 def test_list_ignore_removed (self ):
480492 def side_effect (* args , ** kwargs ):
481493 raise docker .errors .NotFound ('Container not found' )
494+
482495 client = make_fake_client ({
483496 'inspect_container.side_effect' : side_effect
484497 })
0 commit comments