Initial patch to begin adding support for Magnum.
[snaps.git] / snaps / openstack / utils / tests / magnum_utils_tests.py
1 # Copyright (c) 2017 Cable Television Laboratories, Inc. ("CableLabs")
2 #                    and others.  All rights reserved.
3 #
4 # Licensed under the Apache License, Version 2.0 (the "License");
5 # you may not use this file except in compliance with the License.
6 # You may obtain 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,
12 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 # See the License for the specific language governing permissions and
14 # limitations under the License.
15 import logging
16
17 from snaps.openstack.os_credentials import OSCreds
18 from snaps.openstack.tests.os_source_file_test import OSComponentTestCase
19 from snaps.openstack.utils import magnum_utils
20
21 __author__ = 'spisarski'
22
23 logger = logging.getLogger('nova_utils_tests')
24
25
26 class MagnumSmokeTests(OSComponentTestCase):
27     """
28     Tests to ensure that the magnum client can communicate with the cloud
29     """
30
31     def test_connect_success(self):
32         """
33         Tests to ensure that the proper credentials can connect.
34         """
35         magnum = magnum_utils.magnum_client(self.os_creds)
36
37         # This should not throw an exception
38         magnum.clusters.list()
39
40     def test_nova_connect_fail(self):
41         """
42         Tests to ensure that the improper credentials cannot connect.
43         """
44
45         with self.assertRaises(RuntimeError):
46             magnum_utils.magnum_client(
47                 OSCreds(username='user', password='pass',
48                         auth_url=self.os_creds.auth_url,
49                         project_name=self.os_creds.project_name,
50                         proxy_settings=self.os_creds.proxy_settings))