summaryrefslogtreecommitdiff
path: root/tests/unit/client_test.py
diff options
context:
space:
mode:
authorJoffrey F <joffrey@docker.com>2018-01-25 14:17:26 -0800
committerJoffrey F <joffrey@docker.com>2018-01-25 17:32:07 -0800
commit33db9d78ce8903b03175e8ad8c5a0ba9865bf2e4 (patch)
tree749e2db6d5f247845094c9240887616e7714b16b /tests/unit/client_test.py
parent9e2148dcc417c1fd613a69ee558c64349b30173d (diff)
downloaddocker-py-bump_api_version_1.35.tar.gz
Bump default API version to 1.35bump_api_version_1.35
Add ContainerSpec.isolation support Add until support in logs Add condition support in wait Add workdir support in exec_create Signed-off-by: Joffrey F <joffrey@docker.com>
Diffstat (limited to 'tests/unit/client_test.py')
-rw-r--r--tests/unit/client_test.py24
1 files changed, 16 insertions, 8 deletions
diff --git a/tests/unit/client_test.py b/tests/unit/client_test.py
index c4996f1..617b89a 100644
--- a/tests/unit/client_test.py
+++ b/tests/unit/client_test.py
@@ -18,39 +18,45 @@ except ImportError:
TEST_CERT_DIR = os.path.join(os.path.dirname(__file__), 'testdata/certs')
+def docker_from_env(*args, **kwargs):
+ return docker.from_env(
+ *args, environment={'DOCKER_HOST': 'https://unittest:8080'}, **kwargs
+ )
+
+
class ClientTest(unittest.TestCase):
@mock.patch('docker.api.APIClient.events')
def test_events(self, mock_func):
since = datetime.datetime(2016, 1, 1, 0, 0)
mock_func.return_value = fake_api.get_fake_events()[1]
- client = docker.from_env()
+ client = docker_from_env()
assert client.events(since=since) == mock_func.return_value
mock_func.assert_called_with(since=since)
@mock.patch('docker.api.APIClient.info')
def test_info(self, mock_func):
mock_func.return_value = fake_api.get_fake_info()[1]
- client = docker.from_env()
+ client = docker_from_env()
assert client.info() == mock_func.return_value
mock_func.assert_called_with()
@mock.patch('docker.api.APIClient.ping')
def test_ping(self, mock_func):
mock_func.return_value = True
- client = docker.from_env()
+ client = docker_from_env()
assert client.ping() is True
mock_func.assert_called_with()
@mock.patch('docker.api.APIClient.version')
def test_version(self, mock_func):
mock_func.return_value = fake_api.get_fake_version()[1]
- client = docker.from_env()
+ client = docker_from_env()
assert client.version() == mock_func.return_value
mock_func.assert_called_with()
def test_call_api_client_method(self):
- client = docker.from_env()
+ client = docker_from_env()
with self.assertRaises(AttributeError) as cm:
client.create_container()
s = str(cm.exception)
@@ -64,7 +70,9 @@ class ClientTest(unittest.TestCase):
assert "this method is now on the object APIClient" not in s
def test_call_containers(self):
- client = docker.DockerClient(**kwargs_from_env())
+ client = docker.DockerClient(
+ base_url='https://unittest:8080', **kwargs_from_env()
+ )
with self.assertRaises(TypeError) as cm:
client.containers()
@@ -101,11 +109,11 @@ class FromEnvTest(unittest.TestCase):
self.assertEqual(client.api._version, '2.32')
def test_from_env_without_version_uses_default(self):
- client = docker.from_env()
+ client = docker_from_env()
self.assertEqual(client.api._version, DEFAULT_DOCKER_API_VERSION)
def test_from_env_without_timeout_uses_default(self):
- client = docker.from_env()
+ client = docker_from_env()
self.assertEqual(client.api.timeout, DEFAULT_TIMEOUT_SECONDS)