Move cli tests to a new testing package.

These cli tests are now a different kind of that that run the compose binary. They are not the same as integration tests that test some internal interface.

Signed-off-by: Daniel Nephin <dnephin@docker.com>
This commit is contained in:
Daniel Nephin 2015-11-02 17:52:37 -05:00
parent 7f2f4eef48
commit 4105c3017c
3 changed files with 12 additions and 23 deletions

View File

View File

@ -6,12 +6,10 @@ import subprocess
from collections import namedtuple
from operator import attrgetter
import pytest
from .. import mock
from .testcases import DockerClientTestCase
from compose.cli.command import get_project
from compose.cli.docker_client import docker_client
from tests.integration.testcases import DockerClientTestCase
ProcessResult = namedtuple('ProcessResult', 'stdout stderr')
@ -45,8 +43,6 @@ class CLITestCase(DockerClientTestCase):
project_options = project_options or []
proc = subprocess.Popen(
['docker-compose'] + project_options + options,
# Note: this might actually be a patched sys.stdout, so we have
# to specify it here, even though it's the default
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
cwd=self.base_dir)
@ -150,7 +146,7 @@ class CLITestCase(DockerClientTestCase):
assert BUILD_PULL_TEXT in result.stdout
def test_up_detached(self):
self.dispatch(['up', '-d'], None)
self.dispatch(['up', '-d'])
service = self.project.get_service('simple')
another = self.project.get_service('another')
self.assertEqual(len(service.containers()), 1)
@ -162,25 +158,12 @@ class CLITestCase(DockerClientTestCase):
self.assertFalse(container.get('Config.AttachStdout'))
self.assertFalse(container.get('Config.AttachStdin'))
# TODO: needs rework
@pytest.mark.skipif(True, reason="runs top")
def test_up_attached(self):
with mock.patch(
'compose.cli.main.attach_to_logs',
autospec=True
) as mock_attach:
self.dispatch(['up'], None)
_, args, kwargs = mock_attach.mock_calls[0]
_project, log_printer, _names, _timeout = args
self.base_dir = 'tests/fixtures/echo-services'
result = self.dispatch(['up', '--no-color'])
service = self.project.get_service('simple')
another = self.project.get_service('another')
self.assertEqual(len(service.containers()), 1)
self.assertEqual(len(another.containers()), 1)
self.assertEqual(
set(log_printer.containers),
set(self.project.containers())
)
assert 'simple_1 | simple' in result.stdout
assert 'another_1 | another' in result.stdout
def test_up_without_networking(self):
self.require_api_version('1.21')

View File

@ -0,0 +1,6 @@
simple:
image: busybox:latest
command: echo simple
another:
image: busybox:latest
command: echo another