WIP: rename Fig to Compose

Signed-off-by: Aanand Prasad <aanand.prasad@gmail.com>
This commit is contained in:
Aanand Prasad 2015-01-12 14:59:05 +00:00
commit 2af7693e64
54 changed files with 199 additions and 211 deletions

View file

@ -5,7 +5,7 @@ import os
import mock
from tests import unittest
from fig.cli import docker_client
from compose.cli import docker_client
class DockerClientTestCase(unittest.TestCase):

View file

@ -2,7 +2,7 @@ from __future__ import unicode_literals
from __future__ import absolute_import
from tests import unittest
from fig.cli import verbose_proxy
from compose.cli import verbose_proxy
class VerboseProxyTestCase(unittest.TestCase):

View file

@ -6,8 +6,8 @@ from .. import unittest
import mock
from fig.cli import main
from fig.cli.main import TopLevelCommand
from compose.cli import main
from compose.cli.main import TopLevelCommand
from six import StringIO
@ -16,18 +16,18 @@ class CLITestCase(unittest.TestCase):
cwd = os.getcwd()
try:
os.chdir('tests/fixtures/simple-figfile')
os.chdir('tests/fixtures/simple-composefile')
command = TopLevelCommand()
project_name = command.get_project_name(command.get_config_path())
self.assertEquals('simplefigfile', project_name)
self.assertEquals('simplecomposefile', project_name)
finally:
os.chdir(cwd)
def test_project_name_with_explicit_base_dir(self):
command = TopLevelCommand()
command.base_dir = 'tests/fixtures/simple-figfile'
command.base_dir = 'tests/fixtures/simple-composefile'
project_name = command.get_project_name(command.get_config_path())
self.assertEquals('simplefigfile', project_name)
self.assertEquals('simplecomposefile', project_name)
def test_project_name_with_explicit_uppercase_base_dir(self):
command = TopLevelCommand()
@ -41,7 +41,7 @@ class CLITestCase(unittest.TestCase):
project_name = command.get_project_name(None, project_name=name)
self.assertEquals('explicitprojectname', project_name)
def test_project_name_from_environment(self):
def test_project_name_from_environment_old_var(self):
command = TopLevelCommand()
name = 'namefromenv'
with mock.patch.dict(os.environ):
@ -49,18 +49,26 @@ class CLITestCase(unittest.TestCase):
project_name = command.get_project_name(None)
self.assertEquals(project_name, name)
def test_project_name_from_environment_new_var(self):
command = TopLevelCommand()
name = 'namefromenv'
with mock.patch.dict(os.environ):
os.environ['COMPOSE_PROJECT_NAME'] = name
project_name = command.get_project_name(None)
self.assertEquals(project_name, name)
def test_yaml_filename_check(self):
command = TopLevelCommand()
command.base_dir = 'tests/fixtures/longer-filename-figfile'
with mock.patch('fig.cli.command.log', autospec=True) as mock_log:
command.base_dir = 'tests/fixtures/longer-filename-composefile'
with mock.patch('compose.cli.command.log', autospec=True) as mock_log:
self.assertTrue(command.get_config_path())
self.assertEqual(mock_log.warning.call_count, 2)
def test_get_project(self):
command = TopLevelCommand()
command.base_dir = 'tests/fixtures/longer-filename-figfile'
command.base_dir = 'tests/fixtures/longer-filename-composefile'
project = command.get_project(command.get_config_path())
self.assertEqual(project.name, 'longerfilenamefigfile')
self.assertEqual(project.name, 'longerfilenamecomposefile')
self.assertTrue(project.client)
self.assertTrue(project.services)

View file

@ -4,7 +4,7 @@ from .. import unittest
import mock
import docker
from fig.container import Container
from compose.container import Container
class ContainerTest(unittest.TestCase):
@ -20,7 +20,7 @@ class ContainerTest(unittest.TestCase):
"Ports": None,
"SizeRw": 0,
"SizeRootFs": 0,
"Names": ["/figtest_db_1", "/figtest_web_1/db"],
"Names": ["/composetest_db_1", "/composetest_web_1/db"],
"NetworkSettings": {
"Ports": {},
},
@ -33,7 +33,7 @@ class ContainerTest(unittest.TestCase):
self.assertEqual(container.dictionary, {
"Id": "abc",
"Image":"busybox:latest",
"Name": "/figtest_db_1",
"Name": "/composetest_db_1",
})
def test_from_ps_prefixed(self):
@ -45,7 +45,7 @@ class ContainerTest(unittest.TestCase):
self.assertEqual(container.dictionary, {
"Id": "abc",
"Image":"busybox:latest",
"Name": "/figtest_db_1",
"Name": "/composetest_db_1",
})
def test_environment(self):
@ -73,7 +73,7 @@ class ContainerTest(unittest.TestCase):
container = Container.from_ps(None,
self.container_dict,
has_been_inspected=True)
self.assertEqual(container.name, "figtest_db_1")
self.assertEqual(container.name, "composetest_db_1")
def test_name_without_project(self):
container = Container.from_ps(None,

View file

@ -2,7 +2,7 @@ from __future__ import unicode_literals
from __future__ import absolute_import
import os
from fig.cli.log_printer import LogPrinter
from compose.cli.log_printer import LogPrinter
from .. import unittest

View file

@ -5,7 +5,7 @@ from tests import unittest
import mock
from six import StringIO
from fig import progress_stream
from compose import progress_stream
class ProgressStreamTestCase(unittest.TestCase):

View file

@ -1,11 +1,11 @@
from __future__ import unicode_literals
from .. import unittest
from fig.service import Service
from fig.project import Project, ConfigurationError
from compose.service import Service
from compose.project import Project, ConfigurationError
class ProjectTest(unittest.TestCase):
def test_from_dict(self):
project = Project.from_dicts('figtest', [
project = Project.from_dicts('composetest', [
{
'name': 'web',
'image': 'busybox:latest'
@ -22,7 +22,7 @@ class ProjectTest(unittest.TestCase):
self.assertEqual(project.get_service('db').options['image'], 'busybox:latest')
def test_from_dict_sorts_in_dependency_order(self):
project = Project.from_dicts('figtest', [
project = Project.from_dicts('composetest', [
{
'name': 'web',
'image': 'busybox:latest',
@ -45,7 +45,7 @@ class ProjectTest(unittest.TestCase):
self.assertEqual(project.services[2].name, 'web')
def test_from_config(self):
project = Project.from_config('figtest', {
project = Project.from_config('composetest', {
'web': {
'image': 'busybox:latest',
},
@ -61,13 +61,13 @@ class ProjectTest(unittest.TestCase):
def test_from_config_throws_error_when_not_dict(self):
with self.assertRaises(ConfigurationError):
project = Project.from_config('figtest', {
project = Project.from_config('composetest', {
'web': 'busybox:latest',
}, None)
def test_get_service(self):
web = Service(
project='figtest',
project='composetest',
name='web',
client=None,
image="busybox:latest",
@ -77,11 +77,11 @@ class ProjectTest(unittest.TestCase):
def test_get_services_returns_all_services_without_args(self):
web = Service(
project='figtest',
project='composetest',
name='web',
)
console = Service(
project='figtest',
project='composetest',
name='console',
)
project = Project('test', [web, console], None)
@ -89,11 +89,11 @@ class ProjectTest(unittest.TestCase):
def test_get_services_returns_listed_services_with_args(self):
web = Service(
project='figtest',
project='composetest',
name='web',
)
console = Service(
project='figtest',
project='composetest',
name='console',
)
project = Project('test', [web, console], None)
@ -101,20 +101,20 @@ class ProjectTest(unittest.TestCase):
def test_get_services_with_include_links(self):
db = Service(
project='figtest',
project='composetest',
name='db',
)
web = Service(
project='figtest',
project='composetest',
name='web',
links=[(db, 'database')]
)
cache = Service(
project='figtest',
project='composetest',
name='cache'
)
console = Service(
project='figtest',
project='composetest',
name='console',
links=[(web, 'web')]
)
@ -126,11 +126,11 @@ class ProjectTest(unittest.TestCase):
def test_get_services_removes_duplicates_following_links(self):
db = Service(
project='figtest',
project='composetest',
name='db',
)
web = Service(
project='figtest',
project='composetest',
name='web',
links=[(db, 'database')]
)

View file

@ -8,9 +8,9 @@ import mock
import docker
from requests import Response
from fig import Service
from fig.container import Container
from fig.service import (
from compose import Service
from compose.container import Container
from compose.service import (
ConfigError,
split_port,
build_port_bindings,
@ -203,7 +203,7 @@ class ServiceTest(unittest.TestCase):
self.assertRaises(ValueError, service.get_container)
@mock.patch('fig.service.Container', autospec=True)
@mock.patch('compose.service.Container', autospec=True)
def test_get_container(self, mock_container_class):
container_dict = dict(Name='default_foo_2')
self.mock_client.containers.return_value = [container_dict]
@ -214,15 +214,15 @@ class ServiceTest(unittest.TestCase):
mock_container_class.from_ps.assert_called_once_with(
self.mock_client, container_dict)
@mock.patch('fig.service.log', autospec=True)
@mock.patch('compose.service.log', autospec=True)
def test_pull_image(self, mock_log):
service = Service('foo', client=self.mock_client, image='someimage:sometag')
service.pull(insecure_registry=True)
self.mock_client.pull.assert_called_once_with('someimage:sometag', insecure_registry=True)
mock_log.info.assert_called_once_with('Pulling foo (someimage:sometag)...')
@mock.patch('fig.service.Container', autospec=True)
@mock.patch('fig.service.log', autospec=True)
@mock.patch('compose.service.Container', autospec=True)
@mock.patch('compose.service.log', autospec=True)
def test_create_container_from_insecure_registry(
self,
mock_log,

View file

@ -1,4 +1,4 @@
from fig.project import sort_service_dicts, DependencyError
from compose.project import sort_service_dicts, DependencyError
from .. import unittest

View file

@ -1,6 +1,6 @@
from __future__ import unicode_literals
from __future__ import absolute_import
from fig.cli.utils import split_buffer
from compose.cli.utils import split_buffer
from .. import unittest
class SplitBufferTest(unittest.TestCase):