diff options
| author | Zuul <zuul@review.opendev.org> | 2022-11-16 09:20:21 +0000 |
|---|---|---|
| committer | Gerrit Code Review <review@openstack.org> | 2022-11-16 09:20:21 +0000 |
| commit | 16f18d4a8064e0477a29ac741f2413944748720e (patch) | |
| tree | b02abb04c1ef9deeeb534ef43c5e3067d8dd351d /openstackclient/tests | |
| parent | 348eb796321c8475af73b727a310c3a09f519ffa (diff) | |
| parent | ed0d568b948a04e893270d297c538773d058b73e (diff) | |
| download | python-openstackclient-16f18d4a8064e0477a29ac741f2413944748720e.tar.gz | |
Merge "compute: Fix '--network none/auto' handling"
Diffstat (limited to 'openstackclient/tests')
| -rw-r--r-- | openstackclient/tests/unit/compute/v2/test_server.py | 49 |
1 files changed, 37 insertions, 12 deletions
diff --git a/openstackclient/tests/unit/compute/v2/test_server.py b/openstackclient/tests/unit/compute/v2/test_server.py index 858c9a2a..48a36172 100644 --- a/openstackclient/tests/unit/compute/v2/test_server.py +++ b/openstackclient/tests/unit/compute/v2/test_server.py @@ -1675,6 +1675,7 @@ class TestServerCreate(TestServer): '--nic', 'net-id=net1,v4-fixed-ip=10.0.0.2', '--port', 'port1', '--network', 'net1', + '--network', 'auto', # this is a network called 'auto' '--nic', 'port-id=port2', self.new_server.name, ] @@ -1683,24 +1684,40 @@ class TestServerCreate(TestServer): ('flavor', 'flavor1'), ('nics', [ { - 'net-id': 'net1', 'port-id': '', - 'v4-fixed-ip': '', 'v6-fixed-ip': '', + 'net-id': 'net1', + 'port-id': '', + 'v4-fixed-ip': '', + 'v6-fixed-ip': '', }, { - 'net-id': 'net1', 'port-id': '', - 'v4-fixed-ip': '10.0.0.2', 'v6-fixed-ip': '', + 'net-id': 'net1', + 'port-id': '', + 'v4-fixed-ip': '10.0.0.2', + 'v6-fixed-ip': '', }, { - 'net-id': '', 'port-id': 'port1', - 'v4-fixed-ip': '', 'v6-fixed-ip': '', + 'net-id': '', + 'port-id': 'port1', + 'v4-fixed-ip': '', + 'v6-fixed-ip': '', }, { - 'net-id': 'net1', 'port-id': '', - 'v4-fixed-ip': '', 'v6-fixed-ip': '', + 'net-id': 'net1', + 'port-id': '', + 'v4-fixed-ip': '', + 'v6-fixed-ip': '', }, { - 'net-id': '', 'port-id': 'port2', - 'v4-fixed-ip': '', 'v6-fixed-ip': '', + 'net-id': 'auto', + 'port-id': '', + 'v4-fixed-ip': '', + 'v6-fixed-ip': '', + }, + { + 'net-id': '', + 'port-id': 'port2', + 'v4-fixed-ip': '', + 'v6-fixed-ip': '', }, ]), ('config_drive', False), @@ -1729,12 +1746,16 @@ class TestServerCreate(TestServer): "port2": port2_resource}[port_id]) # Mock sdk APIs. - _network = mock.Mock(id='net1_uuid') + _network_1 = mock.Mock(id='net1_uuid') + _network_auto = mock.Mock(id='auto_uuid') _port1 = mock.Mock(id='port1_uuid') _port2 = mock.Mock(id='port2_uuid') find_network = mock.Mock() find_port = mock.Mock() - find_network.return_value = _network + find_network.side_effect = lambda net_id, ignore_missing: { + "net1": _network_1, + "auto": _network_auto, + }[net_id] find_port.side_effect = (lambda port_id, ignore_missing: {"port1": _port1, "port2": _port2}[port_id]) @@ -1775,6 +1796,10 @@ class TestServerCreate(TestServer): 'v4-fixed-ip': '', 'v6-fixed-ip': '', 'port-id': ''}, + {'net-id': 'auto_uuid', + 'v4-fixed-ip': '', + 'v6-fixed-ip': '', + 'port-id': ''}, {'net-id': '', 'v4-fixed-ip': '', 'v6-fixed-ip': '', |
