|
| 1 | +# Copyright (c) 2019 SUSE Linux Products GmbH |
| 2 | +# All Rights Reserved |
| 3 | +# |
| 4 | +# Licensed under the Apache License, Version 2.0 (the "License"); you may |
| 5 | +# not use this file except in compliance with the License. You may obtain |
| 6 | +# a copy of the License at |
| 7 | +# |
| 8 | +# http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | +# |
| 10 | +# Unless required by applicable law or agreed to in writing, software |
| 11 | +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT |
| 12 | +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the |
| 13 | +# License for the specific language governing permissions and limitations |
| 14 | +# under the License. |
| 15 | +# |
| 16 | + |
| 17 | +from openstack.network.v2 import network as _network |
| 18 | +from openstack.network.v2 import subnet_pool as _subnet_pool |
| 19 | + |
| 20 | +from openstackclient.network.v2 import subnet_onboard |
| 21 | +from openstackclient.tests.unit.network.v2 import fakes as network_fakes |
| 22 | + |
| 23 | + |
| 24 | +class TestNetworkOnboardSubnets(network_fakes.TestNetworkV2): |
| 25 | + def setUp(self): |
| 26 | + super().setUp() |
| 27 | + |
| 28 | + self._subnet_pool = _subnet_pool.SubnetPool( |
| 29 | + id='my_subnetpool_id', name='my_subnetpool' |
| 30 | + ) |
| 31 | + self._network = _network.Network(id='my_network_id', name='my_network') |
| 32 | + |
| 33 | + self.network_client.find_subnet_pool.return_value = self._subnet_pool |
| 34 | + self.network_client.find_network.return_value = self._network |
| 35 | + |
| 36 | + self.cmd = subnet_onboard.NetworkOnboardSubnets(self.app, None) |
| 37 | + |
| 38 | + def test_onboard_subnets(self): |
| 39 | + arglist = ['my_network', 'my_subnetpool'] |
| 40 | + verifylist = [ |
| 41 | + ('network', 'my_network'), |
| 42 | + ('subnetpool', 'my_subnetpool'), |
| 43 | + ] |
| 44 | + parsed_args = self.check_parser(self.cmd, arglist, verifylist) |
| 45 | + self.cmd.take_action(parsed_args) |
| 46 | + |
| 47 | + self.network_client.find_network.assert_called_once_with( |
| 48 | + 'my_network', ignore_missing=False |
| 49 | + ) |
| 50 | + self.network_client.find_subnet_pool.assert_called_once_with( |
| 51 | + 'my_subnetpool', ignore_missing=False |
| 52 | + ) |
| 53 | + self.network_client.onboard_network_subnets.assert_called_once_with( |
| 54 | + self._subnet_pool, self._network |
| 55 | + ) |
0 commit comments