@@ -54,6 +54,7 @@ def test_get_container_name(self):
5454 self .assertIsNone (get_container_name ({}))
5555 self .assertEqual (get_container_name ({'Name' : 'myproject_db_1' }), 'myproject_db_1' )
5656 self .assertEqual (get_container_name ({'Names' : ['/myproject_db_1' , '/myproject_web_1/db' ]}), 'myproject_db_1' )
57+ self .assertEqual (get_container_name ({'Names' : ['/swarm-host-1/myproject_db_1' , '/swarm-host-1/myproject_web_1/db' ]}), 'myproject_db_1' )
5758
5859 def test_containers (self ):
5960 service = Service ('db' , client = self .mock_client , project = 'myproject' )
@@ -69,6 +70,17 @@ def test_containers(self):
6970 ]
7071 self .assertEqual ([c .id for c in service .containers ()], ['IN_1' ])
7172
73+ def test_containers_prefixed (self ):
74+ service = Service ('db' , client = self .mock_client , project = 'myproject' )
75+
76+ self .mock_client .containers .return_value = [
77+ {'Image' : 'busybox' , 'Id' : 'OUT_1' , 'Names' : ['/swarm-host-1/myproject' , '/swarm-host-1/foo/bar' ]},
78+ {'Image' : 'busybox' , 'Id' : 'OUT_2' , 'Names' : ['/swarm-host-1/myproject_db' ]},
79+ {'Image' : 'busybox' , 'Id' : 'OUT_3' , 'Names' : ['/swarm-host-1/db_1' ]},
80+ {'Image' : 'busybox' , 'Id' : 'IN_1' , 'Names' : ['/swarm-host-1/myproject_db_1' , '/swarm-host-1/myproject_web_1/db' ]},
81+ ]
82+ self .assertEqual ([c .id for c in service .containers ()], ['IN_1' ])
83+
7284 def test_get_volumes_from_container (self ):
7385 container_id = 'aabbccddee'
7486 service = Service (
0 commit comments