|
@@ -12,8 +12,9 @@ from compose.container import get_container_name
|
|
|
class ContainerTest(unittest.TestCase):
|
|
|
|
|
|
def setUp(self):
|
|
|
+ self.container_id = "abcabcabcbabc12345"
|
|
|
self.container_dict = {
|
|
|
- "Id": "abc",
|
|
|
+ "Id": self.container_id,
|
|
|
"Image": "busybox:latest",
|
|
|
"Command": "top",
|
|
|
"Created": 1387384730,
|
|
@@ -41,19 +42,22 @@ class ContainerTest(unittest.TestCase):
|
|
|
self.assertEqual(
|
|
|
container.dictionary,
|
|
|
{
|
|
|
- "Id": "abc",
|
|
|
+ "Id": self.container_id,
|
|
|
"Image": "busybox:latest",
|
|
|
"Name": "/composetest_db_1",
|
|
|
})
|
|
|
|
|
|
def test_from_ps_prefixed(self):
|
|
|
- self.container_dict['Names'] = ['/swarm-host-1' + n for n in self.container_dict['Names']]
|
|
|
-
|
|
|
- container = Container.from_ps(None,
|
|
|
- self.container_dict,
|
|
|
- has_been_inspected=True)
|
|
|
+ self.container_dict['Names'] = [
|
|
|
+ '/swarm-host-1' + n for n in self.container_dict['Names']
|
|
|
+ ]
|
|
|
+
|
|
|
+ container = Container.from_ps(
|
|
|
+ None,
|
|
|
+ self.container_dict,
|
|
|
+ has_been_inspected=True)
|
|
|
self.assertEqual(container.dictionary, {
|
|
|
- "Id": "abc",
|
|
|
+ "Id": self.container_id,
|
|
|
"Image": "busybox:latest",
|
|
|
"Name": "/composetest_db_1",
|
|
|
})
|
|
@@ -142,6 +146,10 @@ class ContainerTest(unittest.TestCase):
|
|
|
self.assertEqual(container.get('HostConfig.VolumesFrom'), ["volume_id"])
|
|
|
self.assertEqual(container.get('Foo.Bar.DoesNotExist'), None)
|
|
|
|
|
|
+ def test_short_id(self):
|
|
|
+ container = Container(None, self.container_dict, has_been_inspected=True)
|
|
|
+ assert container.short_id == self.container_id[:12]
|
|
|
+
|
|
|
|
|
|
class GetContainerNameTestCase(unittest.TestCase):
|
|
|
|