blob: 75f3199c6839fab567184737988ceebc33c91029 [file] [log] [blame]
Andrea Frittolie258cd72014-07-17 04:47:26 +01001# Copyright 2014 Hewlett-Packard Development Company, L.P.
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
16from tempest.api.compute import base
17from tempest import config
18
19CONF = config.CONF
20
21
22class NetworksTest(base.BaseComputeAdminTest):
23 _api_version = 2
24
25 """
26 Tests Nova Networks API that usually requires admin privileges.
27 API docs:
28 http://developer.openstack.org/api-ref-compute-v2-ext.html#ext-os-networks
29 """
30
31 @classmethod
Andrea Frittoli50bb80d2014-09-15 12:34:27 +010032 def resource_setup(cls):
33 super(NetworksTest, cls).resource_setup()
Andrea Frittolie258cd72014-07-17 04:47:26 +010034 cls.client = cls.os_adm.networks_client
35
36 def test_get_network(self):
37 resp, networks = self.client.list_networks()
38 configured_network = [x for x in networks if x['label'] ==
39 CONF.compute.fixed_network_name]
40 self.assertEqual(1, len(configured_network),
41 "{0} networks with label {1}".format(
42 len(configured_network),
43 CONF.compute.fixed_network_name))
44 configured_network = configured_network[0]
45 _, network = self.client.get_network(configured_network['id'])
46 self.assertEqual(configured_network['label'], network['label'])
47
48 def test_list_all_networks(self):
49 _, networks = self.client.list_networks()
50 # Check the configured network is in the list
51 configured_network = CONF.compute.fixed_network_name
52 self.assertIn(configured_network, [x['label'] for x in networks])