Skip to content

Commit 1f8cde8

Browse files
committed
Integration tests fixes
1 parent 43c3346 commit 1f8cde8

File tree

1 file changed

+15
-35
lines changed

1 file changed

+15
-35
lines changed

tests/integration_test.py

Lines changed: 15 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -907,17 +907,20 @@ def runTest(self):
907907
class TestRestartingContainer(BaseTestCase):
908908
def runTest(self):
909909
container = self.client.create_container(
910-
'busybox', ['false'], host_config=create_host_config(
911-
restart_policy={"Name": "on-failure", "MaximumRetryCount": 1}
910+
'busybox', ['sleep', '2'], host_config=create_host_config(
911+
restart_policy={"Name": "always", "MaximumRetryCount": 0}
912912
)
913913
)
914914
id = container['Id']
915915
self.client.start(id)
916916
self.client.wait(id)
917-
self.client.remove_container(id)
918-
containers = self.client.containers(all=True)
919-
res = [x for x in containers if 'Id' in x and x['Id'].startswith(id)]
920-
self.assertEqual(len(res), 0)
917+
with self.assertRaises(docker.errors.APIError) as exc:
918+
self.client.remove_container(id)
919+
err = exc.exception.response.text
920+
self.assertTrue(
921+
err.startswith('You cannot remove a running container')
922+
)
923+
self.client.remove_container(id, force=True)
921924

922925

923926
class TestExecuteCommand(BaseTestCase):
@@ -1121,7 +1124,7 @@ def runTest(self):
11211124
self.assertIn('Id', res)
11221125
img_id = res['Id']
11231126
self.tmp_imgs.append(img_id)
1124-
self.client.remove_image(img_id)
1127+
self.client.remove_image(img_id, force=True)
11251128
images = self.client.images(all=True)
11261129
res = [x for x in images if x['Id'].startswith(img_id)]
11271130
self.assertEqual(len(res), 0)
@@ -1203,32 +1206,6 @@ def runTest(self):
12031206
self.assertNotEqual(logs, '')
12041207

12051208

1206-
class TestBuildWithAuth(BaseTestCase):
1207-
def runTest(self):
1208-
if compare_version(self.client._version, '1.9') >= 0:
1209-
return
1210-
1211-
k = 'K4104GON3P4Q6ZUJFZRRC2ZQTBJ5YT0UMZD7TGT7ZVIR8Y05FAH2TJQI6Y90SMIB'
1212-
self.client.login('quay+fortesting', k, registry='https://quay.io/v1/',
1213-
email='')
1214-
1215-
script = io.BytesIO('\n'.join([
1216-
'FROM quay.io/quay/teststuff',
1217-
'MAINTAINER docker-py',
1218-
'RUN mkdir -p /tmp/test',
1219-
]).encode('ascii'))
1220-
1221-
stream = self.client.build(fileobj=script, stream=True)
1222-
logs = ''
1223-
for chunk in stream:
1224-
if six.PY3:
1225-
chunk = chunk.decode('utf-8')
1226-
logs += chunk
1227-
1228-
self.assertNotEqual(logs, '')
1229-
self.assertEqual(logs.find('HTTP code: 403'), -1)
1230-
1231-
12321209
class TestBuildWithDockerignore(Cleanup, BaseTestCase):
12331210
def runTest(self):
12341211
if compare_version(self.client._version, '1.8') >= 0:
@@ -1384,9 +1361,12 @@ def setUp(self):
13841361
self.client = docker.client.Client(timeout=5)
13851362

13861363
def test_443(self):
1364+
dfile = io.BytesIO()
13871365
with self.assertRaises(docker.errors.APIError) as exc:
1388-
self.client.build(fileobj=io.BytesIO(), tag="a/b/c")
1389-
self.assertEqual(exc.response.status_code, 500)
1366+
for line in self.client.build(fileobj=dfile, tag="a/b/c"):
1367+
pass
1368+
self.assertEqual(exc.exception.response.status_code, 500)
1369+
dfile.close()
13901370

13911371

13921372
if __name__ == '__main__':

0 commit comments

Comments
 (0)