[pep8] make test files and config files pep8 valid
Signed-off-by: akoskaaa <akos.hochrein@prezi.com>
This commit is contained in:
parent
9aab7bc242
commit
f9ea5ecf40
13 changed files with 66 additions and 66 deletions
|
|
@ -5,7 +5,7 @@ import os
|
|||
import mock
|
||||
from tests import unittest
|
||||
|
||||
from compose.cli import docker_client
|
||||
from compose.cli import docker_client
|
||||
|
||||
|
||||
class DockerClientTestCase(unittest.TestCase):
|
||||
|
|
|
|||
|
|
@ -151,4 +151,3 @@ def make_files(dirname, filenames):
|
|||
for fname in filenames:
|
||||
with open(os.path.join(dirname, fname), 'w') as f:
|
||||
f.write('')
|
||||
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ from .. import unittest
|
|||
|
||||
from compose import config
|
||||
|
||||
|
||||
class ConfigTest(unittest.TestCase):
|
||||
def test_from_dictionary(self):
|
||||
service_dicts = config.from_dictionary({
|
||||
|
|
@ -82,7 +83,7 @@ class MergeTest(unittest.TestCase):
|
|||
|
||||
class EnvTest(unittest.TestCase):
|
||||
def test_parse_environment_as_list(self):
|
||||
environment =[
|
||||
environment = [
|
||||
'NORMAL=F1',
|
||||
'CONTAINS_EQUALS=F=2',
|
||||
'TRAILING_EQUALS=',
|
||||
|
|
@ -114,9 +115,8 @@ class EnvTest(unittest.TestCase):
|
|||
os.environ['ENV_DEF'] = 'E3'
|
||||
|
||||
service_dict = config.make_service_dict(
|
||||
'foo',
|
||||
{
|
||||
'environment': {
|
||||
'foo', {
|
||||
'environment': {
|
||||
'FILE_DEF': 'F1',
|
||||
'FILE_DEF_EMPTY': '',
|
||||
'ENV_DEF': None,
|
||||
|
|
@ -174,6 +174,7 @@ class EnvTest(unittest.TestCase):
|
|||
{'FILE_DEF': 'F1', 'FILE_DEF_EMPTY': '', 'ENV_DEF': 'E3', 'NO_DEF': ''},
|
||||
)
|
||||
|
||||
|
||||
class ExtendsTest(unittest.TestCase):
|
||||
def test_extends(self):
|
||||
service_dicts = config.load('tests/fixtures/extends/docker-compose.yml')
|
||||
|
|
@ -231,7 +232,6 @@ class ExtendsTest(unittest.TestCase):
|
|||
],
|
||||
)
|
||||
|
||||
|
||||
def test_extends_validation(self):
|
||||
dictionary = {'extends': None}
|
||||
load_config = lambda: config.make_service_dict('myweb', dictionary, working_dir='tests/fixtures/extends')
|
||||
|
|
|
|||
|
|
@ -9,7 +9,6 @@ from compose.container import Container
|
|||
|
||||
class ContainerTest(unittest.TestCase):
|
||||
|
||||
|
||||
def setUp(self):
|
||||
self.container_dict = {
|
||||
"Id": "abc",
|
||||
|
|
@ -30,11 +29,13 @@ class ContainerTest(unittest.TestCase):
|
|||
container = Container.from_ps(None,
|
||||
self.container_dict,
|
||||
has_been_inspected=True)
|
||||
self.assertEqual(container.dictionary, {
|
||||
"Id": "abc",
|
||||
"Image":"busybox:latest",
|
||||
"Name": "/composetest_db_1",
|
||||
})
|
||||
self.assertEqual(
|
||||
container.dictionary,
|
||||
{
|
||||
"Id": "abc",
|
||||
"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']]
|
||||
|
|
@ -44,7 +45,7 @@ class ContainerTest(unittest.TestCase):
|
|||
has_been_inspected=True)
|
||||
self.assertEqual(container.dictionary, {
|
||||
"Id": "abc",
|
||||
"Image":"busybox:latest",
|
||||
"Image": "busybox:latest",
|
||||
"Name": "/composetest_db_1",
|
||||
})
|
||||
|
||||
|
|
@ -100,7 +101,7 @@ class ContainerTest(unittest.TestCase):
|
|||
|
||||
def test_human_readable_ports_public_and_private(self):
|
||||
self.container_dict['NetworkSettings']['Ports'].update({
|
||||
"45454/tcp": [ { "HostIp": "0.0.0.0", "HostPort": "49197" } ],
|
||||
"45454/tcp": [{"HostIp": "0.0.0.0", "HostPort": "49197"}],
|
||||
"45453/tcp": [],
|
||||
})
|
||||
container = Container(None, self.container_dict, has_been_inspected=True)
|
||||
|
|
@ -110,7 +111,7 @@ class ContainerTest(unittest.TestCase):
|
|||
|
||||
def test_get_local_port(self):
|
||||
self.container_dict['NetworkSettings']['Ports'].update({
|
||||
"45454/tcp": [ { "HostIp": "0.0.0.0", "HostPort": "49197" } ],
|
||||
"45454/tcp": [{"HostIp": "0.0.0.0", "HostPort": "49197"}],
|
||||
})
|
||||
container = Container(None, self.container_dict, has_been_inspected=True)
|
||||
|
||||
|
|
@ -120,12 +121,12 @@ class ContainerTest(unittest.TestCase):
|
|||
|
||||
def test_get(self):
|
||||
container = Container(None, {
|
||||
"Status":"Up 8 seconds",
|
||||
"Status": "Up 8 seconds",
|
||||
"HostConfig": {
|
||||
"VolumesFrom": ["volume_id",]
|
||||
"VolumesFrom": ["volume_id"]
|
||||
},
|
||||
}, has_been_inspected=True)
|
||||
|
||||
self.assertEqual(container.get('Status'), "Up 8 seconds")
|
||||
self.assertEqual(container.get('HostConfig.VolumesFrom'), ["volume_id",])
|
||||
self.assertEqual(container.get('HostConfig.VolumesFrom'), ["volume_id"])
|
||||
self.assertEqual(container.get('Foo.Bar.DoesNotExist'), None)
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ from tests import unittest
|
|||
import mock
|
||||
from six import StringIO
|
||||
|
||||
from compose import progress_stream
|
||||
from compose import progress_stream
|
||||
|
||||
|
||||
class ProgressStreamTestCase(unittest.TestCase):
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@ from compose import config
|
|||
import mock
|
||||
import docker
|
||||
|
||||
|
||||
class ProjectTest(unittest.TestCase):
|
||||
def test_from_dict(self):
|
||||
project = Project.from_dicts('composetest', [
|
||||
|
|
@ -211,7 +212,7 @@ class ProjectTest(unittest.TestCase):
|
|||
}
|
||||
], mock_client)
|
||||
service = project.get_service('test')
|
||||
self.assertEqual(service._get_net(), 'container:'+container_id)
|
||||
self.assertEqual(service._get_net(), 'container:' + container_id)
|
||||
|
||||
def test_use_net_from_service(self):
|
||||
container_name = 'test_aaa_1'
|
||||
|
|
@ -237,4 +238,4 @@ class ProjectTest(unittest.TestCase):
|
|||
], mock_client)
|
||||
|
||||
service = project.get_service('test')
|
||||
self.assertEqual(service._get_net(), 'container:'+container_name)
|
||||
self.assertEqual(service._get_net(), 'container:' + container_name)
|
||||
|
|
|
|||
|
|
@ -146,16 +146,16 @@ class ServiceTest(unittest.TestCase):
|
|||
|
||||
def test_build_port_bindings_with_one_port(self):
|
||||
port_bindings = build_port_bindings(["127.0.0.1:1000:1000"])
|
||||
self.assertEqual(port_bindings["1000"],[("127.0.0.1","1000")])
|
||||
self.assertEqual(port_bindings["1000"], [("127.0.0.1", "1000")])
|
||||
|
||||
def test_build_port_bindings_with_matching_internal_ports(self):
|
||||
port_bindings = build_port_bindings(["127.0.0.1:1000:1000","127.0.0.1:2000:1000"])
|
||||
self.assertEqual(port_bindings["1000"],[("127.0.0.1","1000"),("127.0.0.1","2000")])
|
||||
port_bindings = build_port_bindings(["127.0.0.1:1000:1000", "127.0.0.1:2000:1000"])
|
||||
self.assertEqual(port_bindings["1000"], [("127.0.0.1", "1000"), ("127.0.0.1", "2000")])
|
||||
|
||||
def test_build_port_bindings_with_nonmatching_internal_ports(self):
|
||||
port_bindings = build_port_bindings(["127.0.0.1:1000:1000","127.0.0.1:2000:2000"])
|
||||
self.assertEqual(port_bindings["1000"],[("127.0.0.1","1000")])
|
||||
self.assertEqual(port_bindings["2000"],[("127.0.0.1","2000")])
|
||||
port_bindings = build_port_bindings(["127.0.0.1:1000:1000", "127.0.0.1:2000:2000"])
|
||||
self.assertEqual(port_bindings["1000"], [("127.0.0.1", "1000")])
|
||||
self.assertEqual(port_bindings["2000"], [("127.0.0.1", "2000")])
|
||||
|
||||
def test_split_domainname_none(self):
|
||||
service = Service('foo', hostname='name', client=self.mock_client)
|
||||
|
|
@ -165,29 +165,32 @@ class ServiceTest(unittest.TestCase):
|
|||
self.assertFalse('domainname' in opts, 'domainname')
|
||||
|
||||
def test_split_domainname_fqdn(self):
|
||||
service = Service('foo',
|
||||
hostname='name.domain.tld',
|
||||
client=self.mock_client)
|
||||
service = Service(
|
||||
'foo',
|
||||
hostname='name.domain.tld',
|
||||
client=self.mock_client)
|
||||
self.mock_client.containers.return_value = []
|
||||
opts = service._get_container_create_options({'image': 'foo'})
|
||||
self.assertEqual(opts['hostname'], 'name', 'hostname')
|
||||
self.assertEqual(opts['domainname'], 'domain.tld', 'domainname')
|
||||
|
||||
def test_split_domainname_both(self):
|
||||
service = Service('foo',
|
||||
hostname='name',
|
||||
domainname='domain.tld',
|
||||
client=self.mock_client)
|
||||
service = Service(
|
||||
'foo',
|
||||
hostname='name',
|
||||
domainname='domain.tld',
|
||||
client=self.mock_client)
|
||||
self.mock_client.containers.return_value = []
|
||||
opts = service._get_container_create_options({'image': 'foo'})
|
||||
self.assertEqual(opts['hostname'], 'name', 'hostname')
|
||||
self.assertEqual(opts['domainname'], 'domain.tld', 'domainname')
|
||||
|
||||
def test_split_domainname_weird(self):
|
||||
service = Service('foo',
|
||||
hostname='name.sub',
|
||||
domainname='domain.tld',
|
||||
client=self.mock_client)
|
||||
service = Service(
|
||||
'foo',
|
||||
hostname='name.sub',
|
||||
domainname='domain.tld',
|
||||
client=self.mock_client)
|
||||
self.mock_client.containers.return_value = []
|
||||
opts = service._get_container_create_options({'image': 'foo'})
|
||||
self.assertEqual(opts['hostname'], 'name.sub', 'hostname')
|
||||
|
|
@ -315,4 +318,3 @@ class ServiceVolumesTest(unittest.TestCase):
|
|||
self.assertEqual(
|
||||
binding,
|
||||
('/home/user', dict(bind='/home/user', ro=False)))
|
||||
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ from __future__ import absolute_import
|
|||
from compose.cli.utils import split_buffer
|
||||
from .. import unittest
|
||||
|
||||
|
||||
class SplitBufferTest(unittest.TestCase):
|
||||
def test_single_line_chunks(self):
|
||||
def reader():
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue