@@ -444,6 +444,68 @@ def test_config_dict_with_net_from_container(self):
444
444
}
445
445
self .assertEqual (config_dict , expected )
446
446
447
+ def test_specifies_host_port_with_no_ports (self ):
448
+ service = Service (
449
+ 'foo' ,
450
+ image = 'foo' )
451
+ self .assertEqual (service .specifies_host_port (), False )
452
+
453
+ def test_specifies_host_port_with_container_port (self ):
454
+ service = Service (
455
+ 'foo' ,
456
+ image = 'foo' ,
457
+ ports = ["2000" ])
458
+ self .assertEqual (service .specifies_host_port (), False )
459
+
460
+ def test_specifies_host_port_with_host_port (self ):
461
+ service = Service (
462
+ 'foo' ,
463
+ image = 'foo' ,
464
+ ports = ["1000:2000" ])
465
+ self .assertEqual (service .specifies_host_port (), True )
466
+
467
+ def test_specifies_host_port_with_host_ip_no_port (self ):
468
+ service = Service (
469
+ 'foo' ,
470
+ image = 'foo' ,
471
+ ports = ["127.0.0.1::2000" ])
472
+ self .assertEqual (service .specifies_host_port (), False )
473
+
474
+ def test_specifies_host_port_with_host_ip_and_port (self ):
475
+ service = Service (
476
+ 'foo' ,
477
+ image = 'foo' ,
478
+ ports = ["127.0.0.1:1000:2000" ])
479
+ self .assertEqual (service .specifies_host_port (), True )
480
+
481
+ def test_specifies_host_port_with_container_port_range (self ):
482
+ service = Service (
483
+ 'foo' ,
484
+ image = 'foo' ,
485
+ ports = ["2000-3000" ])
486
+ self .assertEqual (service .specifies_host_port (), False )
487
+
488
+ def test_specifies_host_port_with_host_port_range (self ):
489
+ service = Service (
490
+ 'foo' ,
491
+ image = 'foo' ,
492
+ ports = ["1000-2000:2000-3000" ])
493
+ self .assertEqual (service .specifies_host_port (), True )
494
+
495
+ def test_specifies_host_port_with_host_ip_no_port_range (self ):
496
+ service = Service (
497
+ 'foo' ,
498
+ image = 'foo' ,
499
+ ports = ["127.0.0.1::2000-3000" ])
500
+ self .assertEqual (service .specifies_host_port (), False )
501
+
502
+ def test_specifies_host_port_with_host_ip_and_port_range (self ):
503
+ service = Service (
504
+ 'foo' ,
505
+ image = 'foo' ,
506
+ ports = ["127.0.0.1:1000-2000:2000-3000" ])
507
+ self .assertEqual (service .specifies_host_port (), True )
508
+
447
509
448
510
class NetTestCase (unittest .TestCase ):
449
511
0 commit comments