+ def test_get_deployment_handler_missing_const_vars(self):
+ with mock.patch('functest.ci.prepare_env.'
+ 'factory.Factory.get_handler') as m:
+ CONST.__setattr__('INSTALLER_IP', None)
+ prepare_env.get_deployment_handler()
+ self.assertFalse(m.called)
+
+ CONST.__setattr__('INSTALLER_TYPE', None)
+ prepare_env.get_deployment_handler()
+ self.assertFalse(m.called)
+
+ @mock.patch('functest.ci.prepare_env.logger.debug')
+ def test_get_deployment_handler_missing_print_deploy_info(self,
+ mock_debug):
+ with mock.patch('functest.ci.prepare_env.'
+ 'factory.Factory.get_handler') as m, \
+ mock.patch('functest.ci.prepare_env.'
+ 'ft_utils.get_parameter_from_yaml',
+ side_effect=ValueError):
+ CONST.__setattr__('INSTALLER_IP', 'test_ip')
+ CONST.__setattr__('INSTALLER_TYPE', 'test_inst_type')
+ opnfv_constants.INSTALLERS = ['test_inst_type']
+ prepare_env.get_deployment_handler()
+ msg = ('Printing deployment info is not supported for '
+ 'test_inst_type')
+ mock_debug.assert_any_call(msg)
+ self.assertFalse(m.called)
+
+ @mock.patch('functest.ci.prepare_env.logger.debug')
+ def test_get_deployment_handler_exception(self, mock_debug):
+ with mock.patch('functest.ci.prepare_env.'
+ 'factory.Factory.get_handler',
+ side_effect=Exception), \
+ mock.patch('functest.ci.prepare_env.'
+ 'ft_utils.get_parameter_from_yaml'):
+ CONST.__setattr__('INSTALLER_IP', 'test_ip')
+ CONST.__setattr__('INSTALLER_TYPE', 'test_inst_type')
+ opnfv_constants.INSTALLERS = ['test_inst_type']
+ prepare_env.get_deployment_handler()
+ self.assertTrue(mock_debug.called)
+