|
@@ -1,14 +1,15 @@
|
|
|
from __future__ import unicode_literals
|
|
from __future__ import unicode_literals
|
|
|
-from compose.project import Project, ConfigurationError
|
|
|
|
|
|
|
+from compose import config
|
|
|
|
|
+from compose.project import Project
|
|
|
from compose.container import Container
|
|
from compose.container import Container
|
|
|
from .testcases import DockerClientTestCase
|
|
from .testcases import DockerClientTestCase
|
|
|
|
|
|
|
|
|
|
|
|
|
class ProjectTest(DockerClientTestCase):
|
|
class ProjectTest(DockerClientTestCase):
|
|
|
def test_volumes_from_service(self):
|
|
def test_volumes_from_service(self):
|
|
|
- project = Project.from_config(
|
|
|
|
|
|
|
+ project = Project.from_dicts(
|
|
|
name='composetest',
|
|
name='composetest',
|
|
|
- config={
|
|
|
|
|
|
|
+ service_dicts=config.from_dictionary({
|
|
|
'data': {
|
|
'data': {
|
|
|
'image': 'busybox:latest',
|
|
'image': 'busybox:latest',
|
|
|
'volumes': ['/var/data'],
|
|
'volumes': ['/var/data'],
|
|
@@ -17,7 +18,7 @@ class ProjectTest(DockerClientTestCase):
|
|
|
'image': 'busybox:latest',
|
|
'image': 'busybox:latest',
|
|
|
'volumes_from': ['data'],
|
|
'volumes_from': ['data'],
|
|
|
},
|
|
},
|
|
|
- },
|
|
|
|
|
|
|
+ }),
|
|
|
client=self.client,
|
|
client=self.client,
|
|
|
)
|
|
)
|
|
|
db = project.get_service('db')
|
|
db = project.get_service('db')
|
|
@@ -31,14 +32,14 @@ class ProjectTest(DockerClientTestCase):
|
|
|
volumes=['/var/data'],
|
|
volumes=['/var/data'],
|
|
|
name='composetest_data_container',
|
|
name='composetest_data_container',
|
|
|
)
|
|
)
|
|
|
- project = Project.from_config(
|
|
|
|
|
|
|
+ project = Project.from_dicts(
|
|
|
name='composetest',
|
|
name='composetest',
|
|
|
- config={
|
|
|
|
|
|
|
+ service_dicts=config.from_dictionary({
|
|
|
'db': {
|
|
'db': {
|
|
|
'image': 'busybox:latest',
|
|
'image': 'busybox:latest',
|
|
|
'volumes_from': ['composetest_data_container'],
|
|
'volumes_from': ['composetest_data_container'],
|
|
|
},
|
|
},
|
|
|
- },
|
|
|
|
|
|
|
+ }),
|
|
|
client=self.client,
|
|
client=self.client,
|
|
|
)
|
|
)
|
|
|
db = project.get_service('db')
|
|
db = project.get_service('db')
|
|
@@ -48,9 +49,9 @@ class ProjectTest(DockerClientTestCase):
|
|
|
project.remove_stopped()
|
|
project.remove_stopped()
|
|
|
|
|
|
|
|
def test_net_from_service(self):
|
|
def test_net_from_service(self):
|
|
|
- project = Project.from_config(
|
|
|
|
|
|
|
+ project = Project.from_dicts(
|
|
|
name='composetest',
|
|
name='composetest',
|
|
|
- config={
|
|
|
|
|
|
|
+ service_dicts=config.from_dictionary({
|
|
|
'net': {
|
|
'net': {
|
|
|
'image': 'busybox:latest',
|
|
'image': 'busybox:latest',
|
|
|
'command': ["/bin/sleep", "300"]
|
|
'command': ["/bin/sleep", "300"]
|
|
@@ -59,8 +60,8 @@ class ProjectTest(DockerClientTestCase):
|
|
|
'image': 'busybox:latest',
|
|
'image': 'busybox:latest',
|
|
|
'net': 'container:net',
|
|
'net': 'container:net',
|
|
|
'command': ["/bin/sleep", "300"]
|
|
'command': ["/bin/sleep", "300"]
|
|
|
- },
|
|
|
|
|
- },
|
|
|
|
|
|
|
+ },
|
|
|
|
|
+ }),
|
|
|
client=self.client,
|
|
client=self.client,
|
|
|
)
|
|
)
|
|
|
|
|
|
|
@@ -82,14 +83,14 @@ class ProjectTest(DockerClientTestCase):
|
|
|
)
|
|
)
|
|
|
net_container.start()
|
|
net_container.start()
|
|
|
|
|
|
|
|
- project = Project.from_config(
|
|
|
|
|
|
|
+ project = Project.from_dicts(
|
|
|
name='composetest',
|
|
name='composetest',
|
|
|
- config={
|
|
|
|
|
|
|
+ service_dicts=config.from_dictionary({
|
|
|
'web': {
|
|
'web': {
|
|
|
'image': 'busybox:latest',
|
|
'image': 'busybox:latest',
|
|
|
'net': 'container:composetest_net_container'
|
|
'net': 'container:composetest_net_container'
|
|
|
},
|
|
},
|
|
|
- },
|
|
|
|
|
|
|
+ }),
|
|
|
client=self.client,
|
|
client=self.client,
|
|
|
)
|
|
)
|
|
|
|
|
|
|
@@ -257,9 +258,9 @@ class ProjectTest(DockerClientTestCase):
|
|
|
project.remove_stopped()
|
|
project.remove_stopped()
|
|
|
|
|
|
|
|
def test_project_up_starts_depends(self):
|
|
def test_project_up_starts_depends(self):
|
|
|
- project = Project.from_config(
|
|
|
|
|
|
|
+ project = Project.from_dicts(
|
|
|
name='composetest',
|
|
name='composetest',
|
|
|
- config={
|
|
|
|
|
|
|
+ service_dicts=config.from_dictionary({
|
|
|
'console': {
|
|
'console': {
|
|
|
'image': 'busybox:latest',
|
|
'image': 'busybox:latest',
|
|
|
'command': ["/bin/sleep", "300"],
|
|
'command': ["/bin/sleep", "300"],
|
|
@@ -279,7 +280,7 @@ class ProjectTest(DockerClientTestCase):
|
|
|
'net': 'container:net',
|
|
'net': 'container:net',
|
|
|
'links': ['app']
|
|
'links': ['app']
|
|
|
},
|
|
},
|
|
|
- },
|
|
|
|
|
|
|
+ }),
|
|
|
client=self.client,
|
|
client=self.client,
|
|
|
)
|
|
)
|
|
|
project.start()
|
|
project.start()
|
|
@@ -296,9 +297,9 @@ class ProjectTest(DockerClientTestCase):
|
|
|
project.remove_stopped()
|
|
project.remove_stopped()
|
|
|
|
|
|
|
|
def test_project_up_with_no_deps(self):
|
|
def test_project_up_with_no_deps(self):
|
|
|
- project = Project.from_config(
|
|
|
|
|
|
|
+ project = Project.from_dicts(
|
|
|
name='composetest',
|
|
name='composetest',
|
|
|
- config={
|
|
|
|
|
|
|
+ service_dicts=config.from_dictionary({
|
|
|
'console': {
|
|
'console': {
|
|
|
'image': 'busybox:latest',
|
|
'image': 'busybox:latest',
|
|
|
'command': ["/bin/sleep", "300"],
|
|
'command': ["/bin/sleep", "300"],
|
|
@@ -324,7 +325,7 @@ class ProjectTest(DockerClientTestCase):
|
|
|
'links': ['app'],
|
|
'links': ['app'],
|
|
|
'volumes_from': ['vol']
|
|
'volumes_from': ['vol']
|
|
|
},
|
|
},
|
|
|
- },
|
|
|
|
|
|
|
+ }),
|
|
|
client=self.client,
|
|
client=self.client,
|
|
|
)
|
|
)
|
|
|
project.start()
|
|
project.start()
|