mirror of https://github.com/docker/compose.git
Update API version for docker client
Signed-off-by: Ulysses Souza <ulyssessouza@gmail.com>
This commit is contained in:
parent
589179a0e1
commit
c447ff8c2c
|
@ -4,6 +4,7 @@ import ssl
|
||||||
|
|
||||||
import docker
|
import docker
|
||||||
import pytest
|
import pytest
|
||||||
|
from docker.constants import DEFAULT_DOCKER_API_VERSION
|
||||||
|
|
||||||
import compose
|
import compose
|
||||||
from compose import const
|
from compose import const
|
||||||
|
@ -24,18 +25,18 @@ class DockerClientTestCase(unittest.TestCase):
|
||||||
del os.environ['HOME']
|
del os.environ['HOME']
|
||||||
except KeyError:
|
except KeyError:
|
||||||
pass
|
pass
|
||||||
docker_client(os.environ, version=const.API_VERSIONS[const.COMPOSE_SPEC])
|
docker_client(os.environ, version=DEFAULT_DOCKER_API_VERSION)
|
||||||
|
|
||||||
@mock.patch.dict(os.environ)
|
@mock.patch.dict(os.environ)
|
||||||
def test_docker_client_with_custom_timeout(self):
|
def test_docker_client_with_custom_timeout(self):
|
||||||
os.environ['COMPOSE_HTTP_TIMEOUT'] = '123'
|
os.environ['COMPOSE_HTTP_TIMEOUT'] = '123'
|
||||||
client = docker_client(os.environ, version=const.API_VERSIONS[const.COMPOSE_SPEC])
|
client = docker_client(os.environ, version=DEFAULT_DOCKER_API_VERSION)
|
||||||
assert client.timeout == 123
|
assert client.timeout == 123
|
||||||
|
|
||||||
@mock.patch.dict(os.environ)
|
@mock.patch.dict(os.environ)
|
||||||
def test_custom_timeout_error(self):
|
def test_custom_timeout_error(self):
|
||||||
os.environ['COMPOSE_HTTP_TIMEOUT'] = '123'
|
os.environ['COMPOSE_HTTP_TIMEOUT'] = '123'
|
||||||
client = docker_client(os.environ, version=const.API_VERSIONS[const.COMPOSE_SPEC])
|
client = docker_client(os.environ, version=DEFAULT_DOCKER_API_VERSION)
|
||||||
|
|
||||||
with mock.patch('compose.cli.errors.log') as fake_log:
|
with mock.patch('compose.cli.errors.log') as fake_log:
|
||||||
with pytest.raises(errors.ConnectionError):
|
with pytest.raises(errors.ConnectionError):
|
||||||
|
@ -55,7 +56,7 @@ class DockerClientTestCase(unittest.TestCase):
|
||||||
assert '123' in fake_log.error.call_args[0][0]
|
assert '123' in fake_log.error.call_args[0][0]
|
||||||
|
|
||||||
def test_user_agent(self):
|
def test_user_agent(self):
|
||||||
client = docker_client(os.environ, version=const.API_VERSIONS[const.COMPOSE_SPEC])
|
client = docker_client(os.environ, version=DEFAULT_DOCKER_API_VERSION)
|
||||||
expected = "docker-compose/{} docker-py/{} {}/{}".format(
|
expected = "docker-compose/{} docker-py/{} {}/{}".format(
|
||||||
compose.__version__,
|
compose.__version__,
|
||||||
docker.__version__,
|
docker.__version__,
|
||||||
|
|
|
@ -20,6 +20,7 @@ from compose.const import IS_WINDOWS_PLATFORM
|
||||||
from compose.const import LABEL_SERVICE
|
from compose.const import LABEL_SERVICE
|
||||||
from compose.container import Container
|
from compose.container import Container
|
||||||
from compose.project import Project
|
from compose.project import Project
|
||||||
|
from compose.config.environment import Environment
|
||||||
|
|
||||||
|
|
||||||
class CLITestCase(unittest.TestCase):
|
class CLITestCase(unittest.TestCase):
|
||||||
|
@ -77,7 +78,9 @@ class CLITestCase(unittest.TestCase):
|
||||||
|
|
||||||
def test_get_project(self):
|
def test_get_project(self):
|
||||||
base_dir = 'tests/fixtures/longer-filename-composefile'
|
base_dir = 'tests/fixtures/longer-filename-composefile'
|
||||||
project = get_project(base_dir)
|
env = Environment.from_env_file(base_dir)
|
||||||
|
env['COMPOSE_API_VERSION'] = DEFAULT_DOCKER_API_VERSION
|
||||||
|
project = get_project(base_dir, environment=env)
|
||||||
assert project.name == 'longer-filename-composefile'
|
assert project.name == 'longer-filename-composefile'
|
||||||
assert project.client
|
assert project.client
|
||||||
assert project.services
|
assert project.services
|
||||||
|
|
Loading…
Reference in New Issue