mirror of https://github.com/docker/compose.git
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:
parent
7f2f4eef48
commit
4105c3017c
|
@ -6,12 +6,10 @@ import subprocess
|
||||||
from collections import namedtuple
|
from collections import namedtuple
|
||||||
from operator import attrgetter
|
from operator import attrgetter
|
||||||
|
|
||||||
import pytest
|
|
||||||
|
|
||||||
from .. import mock
|
from .. import mock
|
||||||
from .testcases import DockerClientTestCase
|
|
||||||
from compose.cli.command import get_project
|
from compose.cli.command import get_project
|
||||||
from compose.cli.docker_client import docker_client
|
from compose.cli.docker_client import docker_client
|
||||||
|
from tests.integration.testcases import DockerClientTestCase
|
||||||
|
|
||||||
|
|
||||||
ProcessResult = namedtuple('ProcessResult', 'stdout stderr')
|
ProcessResult = namedtuple('ProcessResult', 'stdout stderr')
|
||||||
|
@ -45,8 +43,6 @@ class CLITestCase(DockerClientTestCase):
|
||||||
project_options = project_options or []
|
project_options = project_options or []
|
||||||
proc = subprocess.Popen(
|
proc = subprocess.Popen(
|
||||||
['docker-compose'] + project_options + options,
|
['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,
|
stdout=subprocess.PIPE,
|
||||||
stderr=subprocess.PIPE,
|
stderr=subprocess.PIPE,
|
||||||
cwd=self.base_dir)
|
cwd=self.base_dir)
|
||||||
|
@ -150,7 +146,7 @@ class CLITestCase(DockerClientTestCase):
|
||||||
assert BUILD_PULL_TEXT in result.stdout
|
assert BUILD_PULL_TEXT in result.stdout
|
||||||
|
|
||||||
def test_up_detached(self):
|
def test_up_detached(self):
|
||||||
self.dispatch(['up', '-d'], None)
|
self.dispatch(['up', '-d'])
|
||||||
service = self.project.get_service('simple')
|
service = self.project.get_service('simple')
|
||||||
another = self.project.get_service('another')
|
another = self.project.get_service('another')
|
||||||
self.assertEqual(len(service.containers()), 1)
|
self.assertEqual(len(service.containers()), 1)
|
||||||
|
@ -162,25 +158,12 @@ class CLITestCase(DockerClientTestCase):
|
||||||
self.assertFalse(container.get('Config.AttachStdout'))
|
self.assertFalse(container.get('Config.AttachStdout'))
|
||||||
self.assertFalse(container.get('Config.AttachStdin'))
|
self.assertFalse(container.get('Config.AttachStdin'))
|
||||||
|
|
||||||
# TODO: needs rework
|
|
||||||
@pytest.mark.skipif(True, reason="runs top")
|
|
||||||
def test_up_attached(self):
|
def test_up_attached(self):
|
||||||
with mock.patch(
|
self.base_dir = 'tests/fixtures/echo-services'
|
||||||
'compose.cli.main.attach_to_logs',
|
result = self.dispatch(['up', '--no-color'])
|
||||||
autospec=True
|
|
||||||
) as mock_attach:
|
|
||||||
self.dispatch(['up'], None)
|
|
||||||
_, args, kwargs = mock_attach.mock_calls[0]
|
|
||||||
_project, log_printer, _names, _timeout = args
|
|
||||||
|
|
||||||
service = self.project.get_service('simple')
|
assert 'simple_1 | simple' in result.stdout
|
||||||
another = self.project.get_service('another')
|
assert 'another_1 | another' in result.stdout
|
||||||
self.assertEqual(len(service.containers()), 1)
|
|
||||||
self.assertEqual(len(another.containers()), 1)
|
|
||||||
self.assertEqual(
|
|
||||||
set(log_printer.containers),
|
|
||||||
set(self.project.containers())
|
|
||||||
)
|
|
||||||
|
|
||||||
def test_up_without_networking(self):
|
def test_up_without_networking(self):
|
||||||
self.require_api_version('1.21')
|
self.require_api_version('1.21')
|
|
@ -0,0 +1,6 @@
|
||||||
|
simple:
|
||||||
|
image: busybox:latest
|
||||||
|
command: echo simple
|
||||||
|
another:
|
||||||
|
image: busybox:latest
|
||||||
|
command: echo another
|
Loading…
Reference in New Issue