Ejemplo n.º 1
0
    def test_disable_feature(self):
        """Check that result is changed."""
        set_module_args({'name': 'api', 'state': 'absent'})
        with patch.object(basic.AnsibleModule, 'run_command') as run_command:
            run_command.return_value = 0, '', ''  # successful execution, no output
            with self.assertRaises(AnsibleExitJson) as result:
                icinga2_feature.main()
                self.assertTrue(result.exception.args[0]['changed'])

        self.assertEqual(run_command.call_count, 2)
        self.assertEqual(run_command.call_args[0][0][-1], 'api')
Ejemplo n.º 2
0
    def test_enable_feature_with_check_mode(self):
        """Check that result is changed in check mode."""
        set_module_args({
            'name': 'api',
            '_ansible_check_mode': True,
        })
        with patch.object(basic.AnsibleModule, 'run_command') as run_command:
            run_command.return_value = 0, '', ''  # successful execution, no output
            with self.assertRaises(AnsibleExitJson) as result:
                icinga2_feature.main()
                self.assertTrue(result.exception.args[0]['changed'])

        self.assertEqual(run_command.call_count, 1)