summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorBen Firshman <ben@firshman.co.uk>2016-09-05 16:00:14 +0200
committerBen Firshman <ben@firshman.co.uk>2016-11-22 17:03:03 +0000
commit9daa320454ec0c19035a09b436a41e13c3fb71ad (patch)
tree2e93cbf590547f6de6faeeca08167da48b7c6cf4 /tests
parentc7903f084eb3a7525e21974390b48e2a0dc03732 (diff)
downloaddocker-py-9daa320454ec0c19035a09b436a41e13c3fb71ad.tar.gz
Rename Client to APIClient
Signed-off-by: Ben Firshman <ben@firshman.co.uk>
Diffstat (limited to 'tests')
-rw-r--r--tests/integration/api_build_test.py (renamed from tests/integration/build_test.py)0
-rw-r--r--tests/integration/api_client_test.py (renamed from tests/integration/api_test.py)8
-rw-r--r--tests/integration/api_container_test.py (renamed from tests/integration/container_test.py)0
-rw-r--r--tests/integration/api_exec_test.py (renamed from tests/integration/exec_test.py)0
-rw-r--r--tests/integration/api_healthcheck_test.py (renamed from tests/integration/healthcheck_test.py)5
-rw-r--r--tests/integration/api_image_test.py (renamed from tests/integration/image_test.py)0
-rw-r--r--tests/integration/api_network_test.py (renamed from tests/integration/network_test.py)0
-rw-r--r--tests/integration/api_service_test.py (renamed from tests/integration/service_test.py)0
-rw-r--r--tests/integration/api_swarm_test.py (renamed from tests/integration/swarm_test.py)0
-rw-r--r--tests/integration/api_volume_test.py (renamed from tests/integration/volume_test.py)0
-rw-r--r--tests/integration/base.py3
-rw-r--r--tests/integration/conftest.py3
-rw-r--r--tests/unit/api_build_test.py (renamed from tests/unit/build_test.py)0
-rw-r--r--tests/unit/api_client_test.py (renamed from tests/unit/client_test.py)8
-rw-r--r--tests/unit/api_container_test.py (renamed from tests/unit/container_test.py)22
-rw-r--r--tests/unit/api_exec_test.py (renamed from tests/unit/exec_test.py)0
-rw-r--r--tests/unit/api_image_test.py (renamed from tests/unit/image_test.py)0
-rw-r--r--tests/unit/api_network_test.py (renamed from tests/unit/network_test.py)12
-rw-r--r--tests/unit/api_test.py30
-rw-r--r--tests/unit/api_volume_test.py (renamed from tests/unit/volume_test.py)0
-rw-r--r--tests/unit/utils_test.py15
21 files changed, 55 insertions, 51 deletions
diff --git a/tests/integration/build_test.py b/tests/integration/api_build_test.py
index 2695b92..2695b92 100644
--- a/tests/integration/build_test.py
+++ b/tests/integration/api_build_test.py
diff --git a/tests/integration/api_test.py b/tests/integration/api_client_test.py
index 6b54aa9..270bc3d 100644
--- a/tests/integration/api_test.py
+++ b/tests/integration/api_client_test.py
@@ -25,7 +25,7 @@ class InformationTest(BaseIntegrationTest):
self.assertIn('Debug', res)
def test_search(self):
- client = docker.from_env(timeout=10)
+ client = docker.APIClient(timeout=10, **kwargs_from_env())
res = client.search('busybox')
self.assertTrue(len(res) >= 1)
base_img = [x for x in res if x['name'] == 'busybox']
@@ -114,7 +114,7 @@ class LoadConfigTest(BaseIntegrationTest):
class AutoDetectVersionTest(unittest.TestCase):
def test_client_init(self):
- client = docker.from_env(version='auto')
+ client = docker.APIClient(version='auto', **kwargs_from_env())
client_version = client._version
api_version = client.version(api_version=False)['ApiVersion']
self.assertEqual(client_version, api_version)
@@ -126,7 +126,7 @@ class AutoDetectVersionTest(unittest.TestCase):
class ConnectionTimeoutTest(unittest.TestCase):
def setUp(self):
self.timeout = 0.5
- self.client = docker.client.Client(base_url='http://192.168.10.2:4243',
+ self.client = docker.api.APIClient(base_url='http://192.168.10.2:4243',
timeout=self.timeout)
def test_timeout(self):
@@ -155,7 +155,7 @@ class UnixconnTest(unittest.TestCase):
with warnings.catch_warnings(record=True) as w:
warnings.simplefilter('always')
- client = docker.from_env()
+ client = docker.APIClient(**kwargs_from_env())
client.images()
client.close()
del client
diff --git a/tests/integration/container_test.py b/tests/integration/api_container_test.py
index 71e192f..71e192f 100644
--- a/tests/integration/container_test.py
+++ b/tests/integration/api_container_test.py
diff --git a/tests/integration/exec_test.py b/tests/integration/api_exec_test.py
index f2a8b1f..f2a8b1f 100644
--- a/tests/integration/exec_test.py
+++ b/tests/integration/api_exec_test.py
diff --git a/tests/integration/healthcheck_test.py b/tests/integration/api_healthcheck_test.py
index 9c0f398..afe1dea 100644
--- a/tests/integration/healthcheck_test.py
+++ b/tests/integration/api_healthcheck_test.py
@@ -1,5 +1,4 @@
-from .base import BaseIntegrationTest
-from .base import BUSYBOX
+from .base import BaseAPIIntegrationTest, BUSYBOX
from .. import helpers
SECOND = 1000000000
@@ -12,7 +11,7 @@ def wait_on_health_status(client, container, status):
return helpers.wait_on_condition(condition)
-class HealthcheckTest(BaseIntegrationTest):
+class HealthcheckTest(BaseAPIIntegrationTest):
@helpers.requires_api_version('1.24')
def test_healthcheck_shell_command(self):
diff --git a/tests/integration/image_test.py b/tests/integration/api_image_test.py
index 31d2218..31d2218 100644
--- a/tests/integration/image_test.py
+++ b/tests/integration/api_image_test.py
diff --git a/tests/integration/network_test.py b/tests/integration/api_network_test.py
index 2ff5f02..2ff5f02 100644
--- a/tests/integration/network_test.py
+++ b/tests/integration/api_network_test.py
diff --git a/tests/integration/service_test.py b/tests/integration/api_service_test.py
index 636f507..636f507 100644
--- a/tests/integration/service_test.py
+++ b/tests/integration/api_service_test.py
diff --git a/tests/integration/swarm_test.py b/tests/integration/api_swarm_test.py
index d623b83..d623b83 100644
--- a/tests/integration/swarm_test.py
+++ b/tests/integration/api_swarm_test.py
diff --git a/tests/integration/volume_test.py b/tests/integration/api_volume_test.py
index 329b4e0..329b4e0 100644
--- a/tests/integration/volume_test.py
+++ b/tests/integration/api_volume_test.py
diff --git a/tests/integration/base.py b/tests/integration/base.py
index 3fb25b5..2c7c052 100644
--- a/tests/integration/base.py
+++ b/tests/integration/base.py
@@ -2,6 +2,7 @@ import shutil
import unittest
import docker
+from docker.utils import kwargs_from_env
import six
@@ -23,7 +24,7 @@ class BaseIntegrationTest(unittest.TestCase):
if six.PY2:
self.assertRegex = self.assertRegexpMatches
self.assertCountEqual = self.assertItemsEqual
- self.client = docker.from_env(timeout=60)
+ self.client = docker.APIClient(timeout=60, **kwargs_from_env())
self.tmp_imgs = []
self.tmp_containers = []
self.tmp_folders = []
diff --git a/tests/integration/conftest.py b/tests/integration/conftest.py
index c488f90..7217fe0 100644
--- a/tests/integration/conftest.py
+++ b/tests/integration/conftest.py
@@ -4,6 +4,7 @@ import sys
import warnings
import docker.errors
+from docker.utils import kwargs_from_env
import pytest
from .base import BUSYBOX
@@ -12,7 +13,7 @@ from .base import BUSYBOX
@pytest.fixture(autouse=True, scope='session')
def setup_test_session():
warnings.simplefilter('error')
- c = docker.from_env()
+ c = docker.APIClient(**kwargs_from_env())
try:
c.inspect_image(BUSYBOX)
except docker.errors.NotFound:
diff --git a/tests/unit/build_test.py b/tests/unit/api_build_test.py
index b2705eb..b2705eb 100644
--- a/tests/unit/build_test.py
+++ b/tests/unit/api_build_test.py
diff --git a/tests/unit/client_test.py b/tests/unit/api_client_test.py
index 2a5124b..6fc8202 100644
--- a/tests/unit/client_test.py
+++ b/tests/unit/api_client_test.py
@@ -1,7 +1,7 @@
import os
import unittest
-from docker.client import Client
+from docker.api import APIClient
TEST_CERT_DIR = os.path.join(
os.path.dirname(__file__),
@@ -23,14 +23,14 @@ class ClientTest(unittest.TestCase):
os.environ.update(DOCKER_HOST='tcp://192.168.59.103:2376',
DOCKER_CERT_PATH=TEST_CERT_DIR,
DOCKER_TLS_VERIFY='1')
- client = Client.from_env()
+ client = APIClient.from_env()
self.assertEqual(client.base_url, "https://192.168.59.103:2376")
def test_from_env_with_version(self):
os.environ.update(DOCKER_HOST='tcp://192.168.59.103:2376',
DOCKER_CERT_PATH=TEST_CERT_DIR,
DOCKER_TLS_VERIFY='1')
- client = Client.from_env(version='2.32')
+ client = APIClient.from_env(version='2.32')
self.assertEqual(client.base_url, "https://192.168.59.103:2376")
self.assertEqual(client._version, '2.32')
@@ -47,7 +47,7 @@ class DisableSocketTest(unittest.TestCase):
return self.timeout
def setUp(self):
- self.client = Client()
+ self.client = APIClient()
def test_disable_socket_timeout(self):
"""Test that the timeout is disabled on a generic socket object."""
diff --git a/tests/unit/container_test.py b/tests/unit/api_container_test.py
index 51e8cbb..5eb6c53 100644
--- a/tests/unit/container_test.py
+++ b/tests/unit/api_container_test.py
@@ -1244,7 +1244,7 @@ class ContainerTest(DockerClientTest):
)
def test_logs(self):
- with mock.patch('docker.Client.inspect_container',
+ with mock.patch('docker.api.client.APIClient.inspect_container',
fake_inspect_container):
logs = self.client.logs(fake_api.FAKE_CONTAINER_ID)
@@ -1263,7 +1263,7 @@ class ContainerTest(DockerClientTest):
)
def test_logs_with_dict_instead_of_id(self):
- with mock.patch('docker.Client.inspect_container',
+ with mock.patch('docker.api.client.APIClient.inspect_container',
fake_inspect_container):
logs = self.client.logs({'Id': fake_api.FAKE_CONTAINER_ID})
@@ -1282,7 +1282,7 @@ class ContainerTest(DockerClientTest):
)
def test_log_streaming(self):
- with mock.patch('docker.Client.inspect_container',
+ with mock.patch('docker.api.client.APIClient.inspect_container',
fake_inspect_container):
self.client.logs(fake_api.FAKE_CONTAINER_ID, stream=True,
follow=False)
@@ -1297,7 +1297,7 @@ class ContainerTest(DockerClientTest):
)
def test_log_following(self):
- with mock.patch('docker.Client.inspect_container',
+ with mock.patch('docker.api.client.APIClient.inspect_container',
fake_inspect_container):
self.client.logs(fake_api.FAKE_CONTAINER_ID, stream=False,
follow=True)
@@ -1312,7 +1312,7 @@ class ContainerTest(DockerClientTest):
)
def test_log_following_backwards(self):
- with mock.patch('docker.Client.inspect_container',
+ with mock.patch('docker.api.client.APIClient.inspect_container',
fake_inspect_container):
self.client.logs(fake_api.FAKE_CONTAINER_ID, stream=True)
@@ -1326,7 +1326,7 @@ class ContainerTest(DockerClientTest):
)
def test_log_streaming_and_following(self):
- with mock.patch('docker.Client.inspect_container',
+ with mock.patch('docker.api.client.APIClient.inspect_container',
fake_inspect_container):
self.client.logs(fake_api.FAKE_CONTAINER_ID, stream=True,
follow=True)
@@ -1342,7 +1342,7 @@ class ContainerTest(DockerClientTest):
def test_log_tail(self):
- with mock.patch('docker.Client.inspect_container',
+ with mock.patch('docker.api.client.APIClient.inspect_container',
fake_inspect_container):
self.client.logs(fake_api.FAKE_CONTAINER_ID, stream=False,
follow=False, tail=10)
@@ -1358,7 +1358,7 @@ class ContainerTest(DockerClientTest):
def test_log_since(self):
ts = 809222400
- with mock.patch('docker.Client.inspect_container',
+ with mock.patch('docker.api.client.APIClient.inspect_container',
fake_inspect_container):
self.client.logs(fake_api.FAKE_CONTAINER_ID, stream=False,
follow=False, since=ts)
@@ -1375,7 +1375,7 @@ class ContainerTest(DockerClientTest):
def test_log_since_with_datetime(self):
ts = 809222400
time = datetime.datetime.utcfromtimestamp(ts)
- with mock.patch('docker.Client.inspect_container',
+ with mock.patch('docker.api.client.APIClient.inspect_container',
fake_inspect_container):
self.client.logs(fake_api.FAKE_CONTAINER_ID, stream=False,
follow=False, since=time)
@@ -1391,9 +1391,9 @@ class ContainerTest(DockerClientTest):
def test_log_tty(self):
m = mock.Mock()
- with mock.patch('docker.Client.inspect_container',
+ with mock.patch('docker.api.client.APIClient.inspect_container',
fake_inspect_container_tty):
- with mock.patch('docker.Client._stream_raw_result',
+ with mock.patch('docker.api.client.APIClient._stream_raw_result',
m):
self.client.logs(fake_api.FAKE_CONTAINER_ID,
follow=True, stream=True)
diff --git a/tests/unit/exec_test.py b/tests/unit/api_exec_test.py
index 6ba2a3d..6ba2a3d 100644
--- a/tests/unit/exec_test.py
+++ b/tests/unit/api_exec_test.py
diff --git a/tests/unit/image_test.py b/tests/unit/api_image_test.py
index be9d574..be9d574 100644
--- a/tests/unit/image_test.py
+++ b/tests/unit/api_image_test.py
diff --git a/tests/unit/network_test.py b/tests/unit/api_network_test.py
index 5d1f439..083b2e6 100644
--- a/tests/unit/network_test.py
+++ b/tests/unit/api_network_test.py
@@ -33,7 +33,7 @@ class NetworkTest(DockerClientTest):
get = mock.Mock(return_value=response(
status_code=200, content=json.dumps(networks).encode('utf-8')))
- with mock.patch('docker.Client.get', get):
+ with mock.patch('docker.api.client.APIClient.get', get):
self.assertEqual(self.client.networks(), networks)
self.assertEqual(get.call_args[0][0], url_prefix + 'networks')
@@ -59,7 +59,7 @@ class NetworkTest(DockerClientTest):
network_response = response(status_code=200, content=network_data)
post = mock.Mock(return_value=network_response)
- with mock.patch('docker.Client.post', post):
+ with mock.patch('docker.api.client.APIClient.post', post):
result = self.client.create_network('foo')
self.assertEqual(result, network_data)
@@ -109,7 +109,7 @@ class NetworkTest(DockerClientTest):
network_id = 'abc12345'
delete = mock.Mock(return_value=response(status_code=200))
- with mock.patch('docker.Client.delete', delete):
+ with mock.patch('docker.api.client.APIClient.delete', delete):
self.client.remove_network(network_id)
args = delete.call_args
@@ -130,7 +130,7 @@ class NetworkTest(DockerClientTest):
network_response = response(status_code=200, content=network_data)
get = mock.Mock(return_value=network_response)
- with mock.patch('docker.Client.get', get):
+ with mock.patch('docker.api.client.APIClient.get', get):
result = self.client.inspect_network(network_id)
self.assertEqual(result, network_data)
@@ -145,7 +145,7 @@ class NetworkTest(DockerClientTest):
post = mock.Mock(return_value=response(status_code=201))
- with mock.patch('docker.Client.post', post):
+ with mock.patch('docker.api.client.APIClient.post', post):
self.client.connect_container_to_network(
{'Id': container_id},
network_id,
@@ -174,7 +174,7 @@ class NetworkTest(DockerClientTest):
post = mock.Mock(return_value=response(status_code=201))
- with mock.patch('docker.Client.post', post):
+ with mock.patch('docker.api.client.APIClient.post', post):
self.client.disconnect_container_from_network(
{'Id': container_id}, network_id)
diff --git a/tests/unit/api_test.py b/tests/unit/api_test.py
index 5777ab9..3ab500a 100644
--- a/tests/unit/api_test.py
+++ b/tests/unit/api_test.py
@@ -11,6 +11,7 @@ import time
import unittest
import docker
+from docker.api import APIClient
import requests
from requests.packages import urllib3
import six
@@ -95,12 +96,15 @@ url_prefix = '{0}v{1}/'.format(
class DockerClientTest(unittest.TestCase):
def setUp(self):
self.patcher = mock.patch.multiple(
- 'docker.Client', get=fake_get, post=fake_post, put=fake_put,
+ 'docker.api.client.APIClient',
+ get=fake_get,
+ post=fake_post,
+ put=fake_put,
delete=fake_delete,
_read_from_socket=fake_read_from_socket
)
self.patcher.start()
- self.client = docker.Client()
+ self.client = APIClient()
# Force-clear authconfig to avoid tampering with the tests
self.client._cfg = {'Configs': {}}
@@ -122,7 +126,7 @@ class DockerClientTest(unittest.TestCase):
class DockerApiTest(DockerClientTest):
def test_ctor(self):
with pytest.raises(docker.errors.DockerException) as excinfo:
- docker.Client(version=1.12)
+ APIClient(version=1.12)
self.assertEqual(
str(excinfo.value),
@@ -189,7 +193,7 @@ class DockerApiTest(DockerClientTest):
)
def test_retrieve_server_version(self):
- client = docker.Client(version="auto")
+ client = APIClient(version="auto")
self.assertTrue(isinstance(client._version, six.string_types))
self.assertFalse(client._version == "auto")
client.close()
@@ -269,27 +273,27 @@ class DockerApiTest(DockerClientTest):
return socket_adapter.socket_path
def test_url_compatibility_unix(self):
- c = docker.Client(base_url="unix://socket")
+ c = APIClient(base_url="unix://socket")
assert self._socket_path_for_client_session(c) == '/socket'
def test_url_compatibility_unix_triple_slash(self):
- c = docker.Client(base_url="unix:///socket")
+ c = APIClient(base_url="unix:///socket")
assert self._socket_path_for_client_session(c) == '/socket'
def test_url_compatibility_http_unix_triple_slash(self):
- c = docker.Client(base_url="http+unix:///socket")
+ c = APIClient(base_url="http+unix:///socket")
assert self._socket_path_for_client_session(c) == '/socket'
def test_url_compatibility_http(self):
- c = docker.Client(base_url="http://hostname:1234")
+ c = APIClient(base_url="http://hostname:1234")
assert c.base_url == "http://hostname:1234"
def test_url_compatibility_tcp(self):
- c = docker.Client(base_url="tcp://hostname:1234")
+ c = APIClient(base_url="tcp://hostname:1234")
assert c.base_url == "http://hostname:1234"
@@ -435,7 +439,7 @@ class StreamTest(unittest.TestCase):
b'\r\n'
) + b'\r\n'.join(lines)
- with docker.Client(base_url="http+unix://" + self.socket_file) \
+ with APIClient(base_url="http+unix://" + self.socket_file) \
as client:
for i in range(5):
try:
@@ -455,7 +459,7 @@ class StreamTest(unittest.TestCase):
class UserAgentTest(unittest.TestCase):
def setUp(self):
self.patcher = mock.patch.object(
- docker.Client,
+ APIClient,
'send',
return_value=fake_resp("GET", "%s/version" % fake_api.prefix)
)
@@ -465,7 +469,7 @@ class UserAgentTest(unittest.TestCase):
self.patcher.stop()
def test_default_user_agent(self):
- client = docker.Client()
+ client = APIClient()
client.version()
self.assertEqual(self.mock_send.call_count, 1)
@@ -474,7 +478,7 @@ class UserAgentTest(unittest.TestCase):
self.assertEqual(headers['User-Agent'], expected)
def test_custom_user_agent(self):
- client = docker.Client(user_agent='foo/bar')
+ client = APIClient(user_agent='foo/bar')
client.version()
self.assertEqual(self.mock_send.call_count, 1)
diff --git a/tests/unit/volume_test.py b/tests/unit/api_volume_test.py
index 3909977..3909977 100644
--- a/tests/unit/volume_test.py
+++ b/tests/unit/api_volume_test.py
diff --git a/tests/unit/utils_test.py b/tests/unit/utils_test.py
index 80d156f..57aa226 100644
--- a/tests/unit/utils_test.py
+++ b/tests/unit/utils_test.py
@@ -13,10 +13,8 @@ import unittest
import pytest
import six
-from docker.client import Client
-from docker.constants import (
- DEFAULT_DOCKER_API_VERSION, IS_WINDOWS_PLATFORM
-)
+from docker.api.client import APIClient
+from docker.constants import DEFAULT_DOCKER_API_VERSION, IS_WINDOWS_PLATFORM
from docker.errors import DockerException, InvalidVersion
from docker.utils import (
parse_repository_tag, parse_host, convert_filters, kwargs_from_env,
@@ -47,7 +45,7 @@ class DecoratorsTest(unittest.TestCase):
def f(self, headers=None):
return headers
- client = Client()
+ client = APIClient()
client._auth_configs = {}
g = update_headers(f)
@@ -305,7 +303,7 @@ class KwargsFromEnvTest(unittest.TestCase):
self.assertEqual(False, kwargs['tls'].assert_hostname)
self.assertTrue(kwargs['tls'].verify)
try:
- client = Client(**kwargs)
+ client = APIClient(**kwargs)
self.assertEqual(kwargs['base_url'], client.base_url)
self.assertEqual(kwargs['tls'].ca_cert, client.verify)
self.assertEqual(kwargs['tls'].cert, client.cert)
@@ -324,7 +322,7 @@ class KwargsFromEnvTest(unittest.TestCase):
self.assertEqual(True, kwargs['tls'].assert_hostname)
self.assertEqual(False, kwargs['tls'].verify)
try:
- client = Client(**kwargs)
+ client = APIClient(**kwargs)
self.assertEqual(kwargs['base_url'], client.base_url)
self.assertEqual(kwargs['tls'].cert, client.cert)
self.assertFalse(kwargs['tls'].verify)
@@ -821,6 +819,7 @@ class PortsTest(unittest.TestCase):
self.assertEqual(port_bindings["1000"], [("127.0.0.1", "1000")])
self.assertEqual(port_bindings["2000"], [("127.0.0.1", "2000")])
+
def convert_paths(collection):
if not IS_WINDOWS_PLATFORM:
return collection
@@ -1093,7 +1092,7 @@ class TarTest(unittest.TestCase):
)
-class FormatEnvironmentTest(base.BaseTestCase):
+class FormatEnvironmentTest(unittest.TestCase):
def test_format_env_binary_unicode_value(self):
env_dict = {
'ARTIST_NAME': b'\xec\x86\xa1\xec\xa7\x80\xec\x9d\x80'