bf468489e6dd61f855ee562d68f9444221913ef1
[yardstick.git] / yardstick / tests / unit / common / test_openstack_utils.py
1 #!/usr/bin/env python
2
3 ##############################################################################
4 # Copyright (c) 2016 Huawei Technologies Co.,Ltd and others.
5 #
6 # All rights reserved. This program and the accompanying materials
7 # are made available under the terms of the Apache License, Version 2.0
8 # which accompanies this distribution, and is available at
9 # http://www.apache.org/licenses/LICENSE-2.0
10 ##############################################################################
11
12 # Unittest for yardstick.common.openstack_utils
13
14 from __future__ import absolute_import
15 import unittest
16 import mock
17
18 from yardstick.common import openstack_utils
19
20
21 class GetCredentialsTestCase(unittest.TestCase):
22
23     @mock.patch('yardstick.common.openstack_utils.os')
24     def test_get_credentials(self, _):
25         with mock.patch.dict('os.environ', {'OS_IDENTITY_API_VERSION': '2'},
26                              clear=True):
27             openstack_utils.get_credentials()
28
29
30 class GetHeatApiVersionTestCase(unittest.TestCase):
31
32     def test_get_heat_api_version_check_result(self):
33         API = 'HEAT_API_VERSION'
34         expected_result = '2'
35
36         with mock.patch.dict('os.environ', {API: '2'}, clear=True):
37             api_version = openstack_utils.get_heat_api_version()
38             self.assertEqual(api_version, expected_result)
39
40
41 def main():
42     unittest.main()
43
44
45 if __name__ == '__main__':
46     main()