summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoffrey F <joffrey@docker.com>2015-01-09 14:22:55 -0800
committerJoffrey F <joffrey@docker.com>2015-01-09 14:22:55 -0800
commit1f8cde85606876d85425de6f8a6ccec8b54cfb9f (patch)
treede132cd9e4e960e4284c40362e14da2433513db0
parent43c334656b94858c1c7de8cfc8a3aa3d5ee28509 (diff)
downloaddocker-py-1f8cde85606876d85425de6f8a6ccec8b54cfb9f.tar.gz
Integration tests fixesintegration_fixes
-rw-r--r--tests/integration_test.py50
1 files changed, 15 insertions, 35 deletions
diff --git a/tests/integration_test.py b/tests/integration_test.py
index 4958cca..37e8c58 100644
--- a/tests/integration_test.py
+++ b/tests/integration_test.py
@@ -907,17 +907,20 @@ class TestStartContainerWithLinks(BaseTestCase):
class TestRestartingContainer(BaseTestCase):
def runTest(self):
container = self.client.create_container(
- 'busybox', ['false'], host_config=create_host_config(
- restart_policy={"Name": "on-failure", "MaximumRetryCount": 1}
+ 'busybox', ['sleep', '2'], host_config=create_host_config(
+ restart_policy={"Name": "always", "MaximumRetryCount": 0}
)
)
id = container['Id']
self.client.start(id)
self.client.wait(id)
- self.client.remove_container(id)
- containers = self.client.containers(all=True)
- res = [x for x in containers if 'Id' in x and x['Id'].startswith(id)]
- self.assertEqual(len(res), 0)
+ with self.assertRaises(docker.errors.APIError) as exc:
+ self.client.remove_container(id)
+ err = exc.exception.response.text
+ self.assertTrue(
+ err.startswith('You cannot remove a running container')
+ )
+ self.client.remove_container(id, force=True)
class TestExecuteCommand(BaseTestCase):
@@ -1121,7 +1124,7 @@ class TestRemoveImage(BaseTestCase):
self.assertIn('Id', res)
img_id = res['Id']
self.tmp_imgs.append(img_id)
- self.client.remove_image(img_id)
+ self.client.remove_image(img_id, force=True)
images = self.client.images(all=True)
res = [x for x in images if x['Id'].startswith(img_id)]
self.assertEqual(len(res), 0)
@@ -1203,32 +1206,6 @@ class TestBuildFromStringIO(BaseTestCase):
self.assertNotEqual(logs, '')
-class TestBuildWithAuth(BaseTestCase):
- def runTest(self):
- if compare_version(self.client._version, '1.9') >= 0:
- return
-
- k = 'K4104GON3P4Q6ZUJFZRRC2ZQTBJ5YT0UMZD7TGT7ZVIR8Y05FAH2TJQI6Y90SMIB'
- self.client.login('quay+fortesting', k, registry='https://quay.io/v1/',
- email='')
-
- script = io.BytesIO('\n'.join([
- 'FROM quay.io/quay/teststuff',
- 'MAINTAINER docker-py',
- 'RUN mkdir -p /tmp/test',
- ]).encode('ascii'))
-
- stream = self.client.build(fileobj=script, stream=True)
- logs = ''
- for chunk in stream:
- if six.PY3:
- chunk = chunk.decode('utf-8')
- logs += chunk
-
- self.assertNotEqual(logs, '')
- self.assertEqual(logs.find('HTTP code: 403'), -1)
-
-
class TestBuildWithDockerignore(Cleanup, BaseTestCase):
def runTest(self):
if compare_version(self.client._version, '1.8') >= 0:
@@ -1384,9 +1361,12 @@ class TestRegressions(unittest.TestCase):
self.client = docker.client.Client(timeout=5)
def test_443(self):
+ dfile = io.BytesIO()
with self.assertRaises(docker.errors.APIError) as exc:
- self.client.build(fileobj=io.BytesIO(), tag="a/b/c")
- self.assertEqual(exc.response.status_code, 500)
+ for line in self.client.build(fileobj=dfile, tag="a/b/c"):
+ pass
+ self.assertEqual(exc.exception.response.status_code, 500)
+ dfile.close()
if __name__ == '__main__':