From be0afebc988add3cc54ba69bcde8da3c43281b68 Mon Sep 17 00:00:00 2001 From: Joffrey F Date: Fri, 20 Jun 2014 20:55:49 +0200 Subject: [PATCH] Update unit tests to use API v1.12 --- tests/fake_api.py | 4 ++-- tests/test.py | 22 ++++++++++++++++------ 2 files changed, 18 insertions(+), 8 deletions(-) diff --git a/tests/fake_api.py b/tests/fake_api.py index 15b2bce0..25d5b428 100644 --- a/tests/fake_api.py +++ b/tests/fake_api.py @@ -12,7 +12,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -CURRENT_VERSION = 'v1.9' +CURRENT_VERSION = 'v1.12' FAKE_CONTAINER_ID = '3cc2351ab11b' FAKE_IMAGE_ID = 'e9aa60c60128' @@ -316,7 +316,7 @@ fake_responses = { post_fake_tag_image, '{1}/{0}/containers/3cc2351ab11b/wait'.format(CURRENT_VERSION, prefix): get_fake_wait, - '{1}/{0}/containers/3cc2351ab11b/attach'.format(CURRENT_VERSION, prefix): + '{1}/{0}/containers/3cc2351ab11b/logs'.format(CURRENT_VERSION, prefix): get_fake_logs, '{1}/{0}/containers/3cc2351ab11b/changes'.format(CURRENT_VERSION, prefix): get_fake_diff, diff --git a/tests/test.py b/tests/test.py index fdc3a58d..0a0bcbdc 100644 --- a/tests/test.py +++ b/tests/test.py @@ -339,6 +339,11 @@ class DockerClientTest(unittest.TestCase): try: self.client.create_container('busybox', 'true', volumes_from=vol_names) + except docker.errors.DockerException as e: + self.assertTrue( + docker.utils.compare_version('1.10', self.client._version) >= 0 + ) + return except Exception as e: self.fail('Command should not raise exception: {0}'.format(e)) args = fake_request.call_args @@ -740,8 +745,8 @@ class DockerClientTest(unittest.TestCase): self.fail('Command should not raise exception: {0}'.format(e)) fake_request.assert_called_with( - url_prefix + 'containers/3cc2351ab11b/attach', - params={'stream': 0, 'logs': 1, 'stderr': 1, 'stdout': 1}, + url_prefix + 'containers/3cc2351ab11b/logs', + params={'timestamps': 0, 'follow': 0, 'stderr': 1, 'stdout': 1}, timeout=docker.client.DEFAULT_TIMEOUT_SECONDS, stream=False ) @@ -758,8 +763,8 @@ class DockerClientTest(unittest.TestCase): self.fail('Command should not raise exception: {0}'.format(e)) fake_request.assert_called_with( - url_prefix + 'containers/3cc2351ab11b/attach', - params={'stream': 0, 'logs': 1, 'stderr': 1, 'stdout': 1}, + url_prefix + 'containers/3cc2351ab11b/logs', + params={'timestamps': 0, 'follow': 0, 'stderr': 1, 'stdout': 1}, timeout=docker.client.DEFAULT_TIMEOUT_SECONDS, stream=False ) @@ -776,8 +781,8 @@ class DockerClientTest(unittest.TestCase): self.fail('Command should not raise exception: {0}'.format(e)) fake_request.assert_called_with( - url_prefix + 'containers/3cc2351ab11b/attach', - params={'stream': 1, 'logs': 1, 'stderr': 1, 'stdout': 1}, + url_prefix + 'containers/3cc2351ab11b/logs', + params={'timestamps': 0, 'follow': 1, 'stderr': 1, 'stdout': 1}, timeout=docker.client.DEFAULT_TIMEOUT_SECONDS, stream=True ) @@ -1133,6 +1138,11 @@ class DockerClientTest(unittest.TestCase): try: self.client.insert(fake_api.FAKE_IMAGE_NAME, fake_api.FAKE_URL, fake_api.FAKE_PATH) + except docker.errors.DeprecatedMethod as e: + self.assertTrue( + docker.utils.compare_version('1.12', self.client._version) >= 0 + ) + return except Exception as e: self.fail('Command should not raise exception: {0}'.format(e))