Debian Codegraph @

neutronclient/tests/unit/osc/v2/subnet_onboard/test_network_onboard_subnets.py

raw
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 unittest import mock
18
19 from neutronclient.osc.v2.subnet_onboard import subnet_onboard
20 from neutronclient.tests.unit.osc.v2 import fakes as test_fakes
21
22
23 def _get_id(client, id_or_name, resource):
24 return id_or_name
25
26
27 class TestNetworkOnboardSubnets(test_fakes.TestNeutronClientOSCV2):
28
29 def setUp(self):
30 super(TestNetworkOnboardSubnets, self).setUp()
31 mock.patch(
32 'neutronclient.osc.v2.subnet_onboard.subnet_onboard._get_id',
33 new=_get_id).start()
34
35 self.network_id = 'my_network_id'
36 self.subnetpool_id = 'my_subnetpool_id'
37
38 # Get the command object to test
39 self.cmd = subnet_onboard.NetworkOnboardSubnets(self.app,
40 self.namespace)
41
42 def test_options(self):
43 arglist = [
44 self.network_id,
45 self.subnetpool_id
46 ]
47 verifylist = [
48 ('network', self.network_id),
49 ('subnetpool', self.subnetpool_id),
50 ]
51 parsed_args = self.check_parser(self.cmd, arglist, verifylist)
52 self.cmd.take_action(parsed_args)
53 self.neutronclient.onboard_network_subnets.assert_called_once_with(
54 self.subnetpool_id, {'network_id': self.network_id})