@@ -444,6 +444,61 @@ 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_host_ip_and_port (self ):
448
+ service = Service (
449
+ 'foo' ,
450
+ image = 'foo' ,
451
+ ports = ["127.0.0.1:1000:2000" ])
452
+ self .assertEqual (service .specifies_host_port (), True )
453
+
454
+ def test_specifies_host_port_with_no_ports (self ):
455
+ service = Service (
456
+ 'foo' ,
457
+ image = 'foo' )
458
+ self .assertEqual (service .specifies_host_port (), False )
459
+
460
+ def test_specifies_host_port_with_container_port (self ):
461
+ service = Service (
462
+ 'foo' ,
463
+ image = 'foo' ,
464
+ ports = ["2000" ])
465
+ self .assertEqual (service .specifies_host_port (), False )
466
+
467
+ def test_specifies_host_port_with_host_port (self ):
468
+ service = Service (
469
+ 'foo' ,
470
+ image = 'foo' ,
471
+ ports = ["1000:2000" ])
472
+ self .assertEqual (service .specifies_host_port (), True )
473
+
474
+ def test_specifies_host_port_with_host_ip_no_port (self ):
475
+ service = Service (
476
+ 'foo' ,
477
+ image = 'foo' ,
478
+ ports = ["127.0.0.1::2000" ])
479
+ self .assertEqual (service .specifies_host_port (), False )
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
+
447
502
448
503
class NetTestCase (unittest .TestCase ):
449
504
0 commit comments