(self)
| 43 | assert filters == {'id': ['123']} |
| 44 | |
| 45 | def test_create_network(self): |
| 46 | network_data = { |
| 47 | "id": 'abc12345', |
| 48 | "warning": "", |
| 49 | } |
| 50 | |
| 51 | network_response = response(status_code=200, content=network_data) |
| 52 | post = mock.Mock(return_value=network_response) |
| 53 | |
| 54 | with mock.patch('docker.api.client.APIClient.post', post): |
| 55 | result = self.client.create_network('foo') |
| 56 | assert result == network_data |
| 57 | |
| 58 | assert post.call_args[0][0] == f"{url_prefix}networks/create" |
| 59 | |
| 60 | assert json.loads(post.call_args[1]['data']) == {"Name": "foo"} |
| 61 | |
| 62 | opts = { |
| 63 | 'com.docker.network.bridge.enable_icc': False, |
| 64 | 'com.docker.network.bridge.enable_ip_masquerade': False, |
| 65 | } |
| 66 | self.client.create_network('foo', 'bridge', opts) |
| 67 | |
| 68 | assert json.loads(post.call_args[1]['data']) == { |
| 69 | "Name": "foo", "Driver": "bridge", "Options": opts |
| 70 | } |
| 71 | |
| 72 | ipam_pool_config = IPAMPool(subnet="192.168.52.0/24", |
| 73 | gateway="192.168.52.254") |
| 74 | ipam_config = IPAMConfig(pool_configs=[ipam_pool_config]) |
| 75 | |
| 76 | self.client.create_network("bar", driver="bridge", |
| 77 | ipam=ipam_config) |
| 78 | |
| 79 | assert json.loads(post.call_args[1]['data']) == { |
| 80 | "Name": "bar", |
| 81 | "Driver": "bridge", |
| 82 | "IPAM": { |
| 83 | "Driver": "default", |
| 84 | "Config": [{ |
| 85 | "IPRange": None, |
| 86 | "Gateway": "192.168.52.254", |
| 87 | "Subnet": "192.168.52.0/24", |
| 88 | "AuxiliaryAddresses": None, |
| 89 | }], |
| 90 | } |
| 91 | } |
| 92 | |
| 93 | def test_remove_network(self): |
| 94 | network_id = 'abc12345' |
nothing calls this directly
no test coverage detected