import mock
from functest.opnfv_tests.openstack.tempest import conf_utils
-from functest.opnfv_tests.openstack.tempest import tempest
from functest.utils import config
class OSTempestConfUtilsTesting(unittest.TestCase):
# pylint: disable=too-many-public-methods
- @mock.Mock('os_client_config.make_shade')
- def test_create_res_missing_net_dic(self, *mock_args):
- # pylint: disable=unused-argument
- tempest_resources = tempest.TempestResourcesManager()
- with self.assertRaises(Exception) as context:
- tempest_resources.create()
- msg = 'Failed to create private network'
- self.assertTrue(msg in context.exception)
-
- @mock.Mock('os_client_config.make_shade')
- def test_create_res_missing_image(self, *mock_args):
- # pylint: disable=unused-argument
- tempest_resources = tempest.TempestResourcesManager()
-
- with self.assertRaises(Exception) as context:
- tempest_resources.create()
- msg = 'Failed to create image'
- self.assertTrue(msg in context.exception, msg=str(context.exception))
-
- @mock.Mock('os_client_config.make_shade')
- def test_create_res_missing_flavor(self, *mock_args):
- # pylint: disable=unused-argument
- tempest_resources = tempest.TempestResourcesManager()
- with self.assertRaises(Exception) as context:
- tempest_resources.create()
- msg = 'Failed to create flavor'
- self.assertTrue(msg in context.exception, msg=str(context.exception))
-
@mock.patch('subprocess.check_output')
def test_create_rally_deployment(self, mock_exec):
self.assertEqual(conf_utils.create_rally_deployment(), None)
mock.call(['rally', 'deployment', 'destroy', '--deployment',
str(getattr(config.CONF, 'rally_deployment_name'))]),
mock.call(['rally', 'deployment', 'create', '--fromenv', '--name',
- str(getattr(config.CONF, 'rally_deployment_name'))]),
+ str(getattr(config.CONF, 'rally_deployment_name'))],
+ env=None),
mock.call(['rally', 'deployment', 'check'])]
mock_exec.assert_has_calls(calls)
self.assertTrue(mock_get_did.called)
def _test_missing_param(self, params, image_id, flavor_id, alt=False):
- with mock.patch('functest.opnfv_tests.openstack.tempest.'
- 'conf_utils.ConfigParser.RawConfigParser.'
+ with mock.patch('six.moves.configparser.RawConfigParser.'
'set') as mset, \
- mock.patch('functest.opnfv_tests.openstack.tempest.'
- 'conf_utils.ConfigParser.RawConfigParser.'
+ mock.patch('six.moves.configparser.RawConfigParser.'
'read') as mread, \
- mock.patch('functest.opnfv_tests.openstack.tempest.'
- 'conf_utils.ConfigParser.RawConfigParser.'
+ mock.patch('six.moves.configparser.RawConfigParser.'
'write') as mwrite, \
- mock.patch('__builtin__.open', mock.mock_open()), \
+ mock.patch('six.moves.builtins.open', mock.mock_open()), \
mock.patch('functest.utils.functest_utils.yaml.safe_load',
return_value={'validation': {'ssh_timeout': 300}}):
os.environ['OS_INTERFACE'] = ''