|
1 | 1 | # Copyright 2013 dotCloud inc.
|
2 | 2 |
|
3 |
| -# Licensed under the Apache License, Version 2.0 (the "License"); |
4 |
| -# you may not use this file except in compliance with the License. |
| 3 | +# Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | +# you may not use this file except in compliance with the License. |
5 | 5 | # You may obtain a copy of the License at
|
6 | 6 |
|
7 | 7 | # http://www.apache.org/licenses/LICENSE-2.0
|
@@ -60,6 +60,7 @@ def fake_resp(url, data=None, **kwargs):
|
60 | 60 | status_code, content = fake_api.fake_responses[url]()
|
61 | 61 | return response(status_code=status_code, content=content)
|
62 | 62 |
|
| 63 | + |
63 | 64 | fake_request = mock.Mock(side_effect=fake_resp)
|
64 | 65 | url_prefix = 'http+unix://var/run/docker.sock/v{0}/'.format(
|
65 | 66 | docker.client.DEFAULT_DOCKER_API_VERSION)
|
@@ -616,7 +617,7 @@ def test_start_container_with_binds_rw(self):
|
616 | 617 | mount_origin = '/tmp'
|
617 | 618 | self.client.start(fake_api.FAKE_CONTAINER_ID,
|
618 | 619 | binds={mount_origin: {
|
619 |
| - "bind": mount_dest, "ro": False}}) |
| 620 | + "bind": mount_dest, "ro": False}}) |
620 | 621 | except Exception as e:
|
621 | 622 | self.fail('Command should not raise exception: {0}'.format(e))
|
622 | 623 |
|
@@ -812,6 +813,34 @@ def test_start_container_with_dict_instead_of_id(self):
|
812 | 813 | docker.client.DEFAULT_TIMEOUT_SECONDS
|
813 | 814 | )
|
814 | 815 |
|
| 816 | + def test_start_container_with_restart_policy(self): |
| 817 | + try: |
| 818 | + self.client.start(fake_api.FAKE_CONTAINER_ID, |
| 819 | + restart_policy={ |
| 820 | + "Name": "always", |
| 821 | + "MaximumRetryCount": 0 |
| 822 | + }) |
| 823 | + except Exception as e: |
| 824 | + self.fail('Command should not raise exception: {0}'.format(e)) |
| 825 | + args = fake_request.call_args |
| 826 | + self.assertEqual( |
| 827 | + args[0][0], |
| 828 | + url_prefix + 'containers/3cc2351ab11b/start' |
| 829 | + ) |
| 830 | + self.assertEqual( |
| 831 | + json.loads(args[1]['data']), |
| 832 | + {"PublishAllPorts": False, "Privileged": False, |
| 833 | + "RestartPolicy": {"MaximumRetryCount": 0, "Name": "always"}} |
| 834 | + ) |
| 835 | + self.assertEqual( |
| 836 | + args[1]['headers'], |
| 837 | + {'Content-Type': 'application/json'} |
| 838 | + ) |
| 839 | + self.assertEqual( |
| 840 | + args[1]['timeout'], |
| 841 | + docker.client.DEFAULT_TIMEOUT_SECONDS |
| 842 | + ) |
| 843 | + |
815 | 844 | def test_resize_container(self):
|
816 | 845 | try:
|
817 | 846 | self.client.resize(
|
@@ -1536,11 +1565,11 @@ def test_tar_with_excludes(self):
|
1536 | 1565 | f.write("content")
|
1537 | 1566 |
|
1538 | 1567 | for exclude, names in (
|
1539 |
| - (['*.py'], ['bar/a.txt', 'bar/other.png', |
1540 |
| - 'test/foo/a.txt', 'test/foo/other.png']), |
1541 |
| - (['*.png', 'bar'], ['test/foo/a.txt', 'test/foo/b.py']), |
1542 |
| - (['test/foo', 'a.txt'], ['bar/a.txt', 'bar/b.py', |
1543 |
| - 'bar/other.png']), |
| 1568 | + (['*.py'], ['bar/a.txt', 'bar/other.png', |
| 1569 | + 'test/foo/a.txt', 'test/foo/other.png']), |
| 1570 | + (['*.png', 'bar'], ['test/foo/a.txt', 'test/foo/b.py']), |
| 1571 | + (['test/foo', 'a.txt'], ['bar/a.txt', 'bar/b.py', |
| 1572 | + 'bar/other.png']), |
1544 | 1573 | ):
|
1545 | 1574 | archive = docker.utils.tar(base, exclude=exclude)
|
1546 | 1575 | tar = tarfile.open(fileobj=archive)
|
|
0 commit comments