diff options
author | Aanand Prasad <aanand.prasad@gmail.com> | 2016-01-05 12:55:45 +0000 |
---|---|---|
committer | Aanand Prasad <aanand.prasad@gmail.com> | 2016-01-05 12:55:45 +0000 |
commit | 62d9964cc1881f6f3cd021594cd40fd80a8fc855 (patch) | |
tree | 3e26ffbbe67582f2eb5f5cc36075eeefa82e08b6 /tests | |
parent | 140879d65720646b87fe7a8809a8f2a7846ade39 (diff) | |
parent | 67a29441c4605c4027fa22484f3d14f36349c6bb (diff) | |
download | docker-py-62d9964cc1881f6f3cd021594cd40fd80a8fc855.tar.gz |
Merge pull request #818 from rmb938/patch-1
allow custom ipam options when creating networks
Diffstat (limited to 'tests')
-rw-r--r-- | tests/unit/network_test.py | 24 | ||||
-rw-r--r-- | tests/unit/utils_test.py | 17 |
2 files changed, 40 insertions, 1 deletions
diff --git a/tests/unit/network_test.py b/tests/unit/network_test.py index a41a980..7d2cc9a 100644 --- a/tests/unit/network_test.py +++ b/tests/unit/network_test.py @@ -4,6 +4,7 @@ import six from .. import base from .api_test import DockerClientTest, url_prefix, response +from docker.utils import create_ipam_config, create_ipam_pool try: from unittest import mock @@ -80,6 +81,29 @@ class NetworkTest(DockerClientTest): json.loads(post.call_args[1]['data']), {"name": "foo", "driver": "bridge", "options": opts}) + ipam_pool_config = create_ipam_pool(subnet="192.168.52.0/24", + gateway="192.168.52.254") + ipam_config = create_ipam_config(pool_configs=[ipam_pool_config]) + + self.client.create_network("bar", driver="bridge", + ipam=ipam_config) + + self.assertEqual( + json.loads(post.call_args[1]['data']), + { + "name": "bar", + "driver": "bridge", + "ipam": { + "driver": "default", + "config": [{ + "iprange": None, + "gateway": "192.168.52.254", + "subnet": "192.168.52.0/24", + "auxaddresses": None + }] + } + }) + @base.requires_api_version('1.21') def test_remove_network(self): network_id = 'abc12345' diff --git a/tests/unit/utils_test.py b/tests/unit/utils_test.py index a68e1e7..d436de2 100644 --- a/tests/unit/utils_test.py +++ b/tests/unit/utils_test.py @@ -18,7 +18,7 @@ from docker.utils import ( parse_repository_tag, parse_host, convert_filters, kwargs_from_env, create_host_config, Ulimit, LogConfig, parse_bytes, parse_env_file, exclude_paths, convert_volume_binds, decode_json_header, tar, - split_command, + split_command, create_ipam_config, create_ipam_pool ) from docker.utils.ports import build_port_bindings, split_port @@ -428,6 +428,21 @@ class UtilsTest(base.BaseTestCase): decoded_data = decode_json_header(data) self.assertEqual(obj, decoded_data) + def test_create_ipam_config(self): + ipam_pool = create_ipam_pool(subnet='192.168.52.0/24', + gateway='192.168.52.254') + + ipam_config = create_ipam_config(pool_configs=[ipam_pool]) + self.assertEqual(ipam_config, { + 'driver': 'default', + 'config': [{ + 'subnet': '192.168.52.0/24', + 'gateway': '192.168.52.254', + 'auxaddresses': None, + 'iprange': None + }] + }) + class SplitCommandTest(base.BaseTestCase): |