Пример #1
0
 def test_module_run_test_true(self):
     '''
     Tests the return of module.run state when test=True is passed in
     '''
     with patch.dict(module.__opts__, {'test': True}):
         ret = module._run(CMD)
         comment = 'Module function {0} is set to execute'.format(CMD)
         self.assertEqual(ret['comment'], comment)
Пример #2
0
 def test_module_run_test_true(self):
     """
     Tests the return of module.run state when test=True is passed in
     """
     with patch.dict(module.__opts__, {"test": True}):
         ret = module._run(CMD)
     self.assertEqual(ret["comment"],
                      "Module function {} is set to execute".format(CMD))
Пример #3
0
 def test_module_run_hidden_varargs(self):
     '''
     Tests the return of module.run state when hidden varargs are used with
     wrong type.
     '''
     with patch('salt.utils.args.get_function_argspec', MagicMock(return_value=self.bspec)):
         ret = module._run(CMD, m_names='anyname')
         comment = "'names' must be a list."
         self.assertEqual(ret['comment'], comment)
Пример #4
0
 def test_module_run_hidden_varargs(self):
     """
     Tests the return of module.run state when hidden varargs are used with
     wrong type.
     """
     with patch("salt.utils.args.get_function_argspec",
                MagicMock(return_value=self.bspec)):
         ret = module._run(CMD, m_names="anyname")
     self.assertEqual(ret["comment"], "'names' must be a list.")
Пример #5
0
 def test_module_run_missing_arg(self):
     '''
     Tests the return of module.run state when arguments are missing
     '''
     ret = module._run(CMD)
     comment = 'The following arguments are missing:'
     self.assertIn(comment, ret['comment'])
     self.assertIn('world', ret['comment'])
     self.assertIn('hello', ret['comment'])
Пример #6
0
 def test_module_run_missing_arg(self):
     '''
     Tests the return of module.run state when arguments are missing
     '''
     with patch('salt.utils.args.get_function_argspec', MagicMock(return_value=self.aspec)):
         ret = module._run(CMD)
         comment = 'The following arguments are missing:'
         self.assertIn(comment, ret['comment'])
         self.assertIn('world', ret['comment'])
         self.assertIn('hello', ret['comment'])
Пример #7
0
 def test_module_run_module_not_available(self):
     '''
     Tests the return of module.run state when the module function
     name isn't available
     '''
     with patch.dict(module.__salt__, {}, clear=True):
         ret = module._run(CMD)
         comment = 'Module function {0} is not available'.format(CMD)
         self.assertEqual(ret['comment'], comment)
         self.assertFalse(ret['result'])
Пример #8
0
 def test_module_run_missing_arg(self):
     """
     Tests the return of module.run state when arguments are missing
     """
     with patch("salt.utils.args.get_function_argspec",
                MagicMock(return_value=self.aspec)):
         ret = module._run(CMD)
     self.assertIn("The following arguments are missing:", ret["comment"])
     self.assertIn("world", ret["comment"])
     self.assertIn("hello", ret["comment"])
Пример #9
0
 def test_module_run_module_not_available(self):
     """
     Tests the return of module.run state when the module function
     name isn't available
     """
     with patch.dict(module.__salt__, {}, clear=True):
         ret = module._run(CMD)
     self.assertFalse(ret["result"])
     self.assertEqual(ret["comment"],
                      "Module function {} is not available".format(CMD))