diff options
Diffstat (limited to 'yardstick/tests/unit/common/test_openstack_utils.py')
-rw-r--r-- | yardstick/tests/unit/common/test_openstack_utils.py | 28 |
1 files changed, 19 insertions, 9 deletions
diff --git a/yardstick/tests/unit/common/test_openstack_utils.py b/yardstick/tests/unit/common/test_openstack_utils.py index bf468489e..b685e63be 100644 --- a/yardstick/tests/unit/common/test_openstack_utils.py +++ b/yardstick/tests/unit/common/test_openstack_utils.py @@ -1,5 +1,3 @@ -#!/usr/bin/env python - ############################################################################## # Copyright (c) 2016 Huawei Technologies Co.,Ltd and others. # @@ -9,9 +7,7 @@ # http://www.apache.org/licenses/LICENSE-2.0 ############################################################################## -# Unittest for yardstick.common.openstack_utils - -from __future__ import absolute_import +from oslo_utils import uuidutils import unittest import mock @@ -38,9 +34,23 @@ class GetHeatApiVersionTestCase(unittest.TestCase): self.assertEqual(api_version, expected_result) -def main(): - unittest.main() +class GetNetworkIdTestCase(unittest.TestCase): + + def test_get_network_id(self): + _uuid = uuidutils.generate_uuid() + mock_shade_client = mock.Mock() + mock_shade_client.list_networks = mock.Mock() + mock_shade_client.list_networks.return_value = [{'id': _uuid}] + + output = openstack_utils.get_network_id(mock_shade_client, + 'network_name') + self.assertEqual(_uuid, output) + def test_get_network_id_no_network(self): + mock_shade_client = mock.Mock() + mock_shade_client.list_networks = mock.Mock() + mock_shade_client.list_networks.return_value = None -if __name__ == '__main__': - main() + output = openstack_utils.get_network_id(mock_shade_client, + 'network_name') + self.assertEqual(None, output) |