mirror of https://github.com/docker/compose.git
Fix cherry-pick errors.
Signed-off-by: Daniel Nephin <dnephin@docker.com>
This commit is contained in:
parent
7ff8c2b224
commit
2b75741e5a
|
@ -614,7 +614,7 @@ class Service(object):
|
||||||
container_options.get('labels', {}),
|
container_options.get('labels', {}),
|
||||||
self.labels(one_off=one_off),
|
self.labels(one_off=one_off),
|
||||||
number,
|
number,
|
||||||
self.config_hash if add_config_hash else None)
|
self.config_hash() if add_config_hash else None)
|
||||||
|
|
||||||
# Delete options which are only used when starting
|
# Delete options which are only used when starting
|
||||||
for key in DOCKER_START_KEYS:
|
for key in DOCKER_START_KEYS:
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
|
import mock # noqa
|
||||||
|
|
||||||
if sys.version_info >= (2, 7):
|
if sys.version_info >= (2, 7):
|
||||||
import unittest # NOQA
|
import unittest # NOQA
|
||||||
else:
|
else:
|
||||||
|
|
|
@ -512,7 +512,7 @@ class ExtendsTest(unittest.TestCase):
|
||||||
We specify a 'file' key that is the filename we're already in.
|
We specify a 'file' key that is the filename we're already in.
|
||||||
"""
|
"""
|
||||||
service_dicts = load_from_filename('tests/fixtures/extends/specify-file-as-self.yml')
|
service_dicts = load_from_filename('tests/fixtures/extends/specify-file-as-self.yml')
|
||||||
self.assertEqual(service_dicts, [
|
self.assertEqual(sorted(service_dicts), sorted([
|
||||||
{
|
{
|
||||||
'environment':
|
'environment':
|
||||||
{
|
{
|
||||||
|
@ -532,7 +532,7 @@ class ExtendsTest(unittest.TestCase):
|
||||||
'image': 'busybox',
|
'image': 'busybox',
|
||||||
'name': 'web'
|
'name': 'web'
|
||||||
}
|
}
|
||||||
])
|
]))
|
||||||
|
|
||||||
def test_circular(self):
|
def test_circular(self):
|
||||||
try:
|
try:
|
||||||
|
|
|
@ -7,8 +7,6 @@ import mock
|
||||||
import docker
|
import docker
|
||||||
from docker.utils import LogConfig
|
from docker.utils import LogConfig
|
||||||
|
|
||||||
from .. import mock
|
|
||||||
from .. import unittest
|
|
||||||
from compose.const import LABEL_CONFIG_HASH
|
from compose.const import LABEL_CONFIG_HASH
|
||||||
from compose.const import LABEL_ONE_OFF
|
from compose.const import LABEL_ONE_OFF
|
||||||
from compose.const import LABEL_PROJECT
|
from compose.const import LABEL_PROJECT
|
||||||
|
@ -227,19 +225,6 @@ class ServiceTest(unittest.TestCase):
|
||||||
self.assertEqual(opts['hostname'], 'name.sub', 'hostname')
|
self.assertEqual(opts['hostname'], 'name.sub', 'hostname')
|
||||||
self.assertEqual(opts['domainname'], 'domain.tld', 'domainname')
|
self.assertEqual(opts['domainname'], 'domain.tld', 'domainname')
|
||||||
|
|
||||||
def test_get_container_create_options_with_name_option(self):
|
|
||||||
service = Service(
|
|
||||||
'foo',
|
|
||||||
image='foo',
|
|
||||||
client=self.mock_client,
|
|
||||||
container_name='foo1')
|
|
||||||
name = 'the_new_name'
|
|
||||||
opts = service._get_container_create_options(
|
|
||||||
{'name': name},
|
|
||||||
1,
|
|
||||||
one_off=True)
|
|
||||||
self.assertEqual(opts['name'], name)
|
|
||||||
|
|
||||||
def test_get_container_create_options_does_not_mutate_options(self):
|
def test_get_container_create_options_does_not_mutate_options(self):
|
||||||
labels = {'thing': 'real'}
|
labels = {'thing': 'real'}
|
||||||
environment = {'also': 'real'}
|
environment = {'also': 'real'}
|
||||||
|
@ -274,40 +259,6 @@ class ServiceTest(unittest.TestCase):
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
def test_get_container_create_options_does_not_mutate_options(self):
|
|
||||||
labels = {'thing': 'real'}
|
|
||||||
environment = {'also': 'real'}
|
|
||||||
service = Service(
|
|
||||||
'foo',
|
|
||||||
image='foo',
|
|
||||||
labels=dict(labels),
|
|
||||||
client=self.mock_client,
|
|
||||||
environment=dict(environment),
|
|
||||||
)
|
|
||||||
self.mock_client.inspect_image.return_value = {'Id': 'abcd'}
|
|
||||||
prev_container = mock.Mock(
|
|
||||||
id='ababab',
|
|
||||||
image_config={'ContainerConfig': {}})
|
|
||||||
|
|
||||||
opts = service._get_container_create_options(
|
|
||||||
{},
|
|
||||||
1,
|
|
||||||
previous_container=prev_container)
|
|
||||||
|
|
||||||
self.assertEqual(service.options['labels'], labels)
|
|
||||||
self.assertEqual(service.options['environment'], environment)
|
|
||||||
|
|
||||||
self.assertEqual(
|
|
||||||
opts['labels'][LABEL_CONFIG_HASH],
|
|
||||||
'b30306d0a73b67f67a45b99b88d36c359e470e6fa0c04dda1cf62d2087205b81')
|
|
||||||
self.assertEqual(
|
|
||||||
opts['environment'],
|
|
||||||
{
|
|
||||||
'affinity:container': '=ababab',
|
|
||||||
'also': 'real',
|
|
||||||
}
|
|
||||||
)
|
|
||||||
|
|
||||||
def test_get_container_not_found(self):
|
def test_get_container_not_found(self):
|
||||||
self.mock_client.containers.return_value = []
|
self.mock_client.containers.return_value = []
|
||||||
service = Service('foo', client=self.mock_client, image='foo')
|
service = Service('foo', client=self.mock_client, image='foo')
|
||||||
|
@ -433,9 +384,9 @@ class ServiceTest(unittest.TestCase):
|
||||||
'foo',
|
'foo',
|
||||||
image='example.com/foo',
|
image='example.com/foo',
|
||||||
client=self.mock_client,
|
client=self.mock_client,
|
||||||
net=ServiceNet(Service('other')),
|
net=ServiceNet(Service('other', image='foo')),
|
||||||
links=[(Service('one'), 'one')],
|
links=[(Service('one', image='foo'), 'one')],
|
||||||
volumes_from=[Service('two')])
|
volumes_from=[Service('two', image='foo')])
|
||||||
|
|
||||||
config_dict = service.config_dict()
|
config_dict = service.config_dict()
|
||||||
expected = {
|
expected = {
|
||||||
|
@ -492,7 +443,7 @@ class NetTestCase(unittest.TestCase):
|
||||||
{'Id': container_id, 'Name': container_id, 'Image': 'abcd'},
|
{'Id': container_id, 'Name': container_id, 'Image': 'abcd'},
|
||||||
]
|
]
|
||||||
|
|
||||||
service = Service(name=service_name, client=mock_client)
|
service = Service(name=service_name, client=mock_client, image='foo')
|
||||||
net = ServiceNet(service)
|
net = ServiceNet(service)
|
||||||
|
|
||||||
self.assertEqual(net.id, service_name)
|
self.assertEqual(net.id, service_name)
|
||||||
|
@ -504,7 +455,7 @@ class NetTestCase(unittest.TestCase):
|
||||||
mock_client = mock.create_autospec(docker.Client)
|
mock_client = mock.create_autospec(docker.Client)
|
||||||
mock_client.containers.return_value = []
|
mock_client.containers.return_value = []
|
||||||
|
|
||||||
service = Service(name=service_name, client=mock_client)
|
service = Service(name=service_name, client=mock_client, image='foo')
|
||||||
net = ServiceNet(service)
|
net = ServiceNet(service)
|
||||||
|
|
||||||
self.assertEqual(net.id, service_name)
|
self.assertEqual(net.id, service_name)
|
||||||
|
|
Loading…
Reference in New Issue