Esempio n. 1
0
    def test_get_all_with_filter_and_count(self):
        self.resource.get_all.return_value = ALL_ALERTS
        self.mock_ansible_instance.params = copy.deepcopy(PARAMS_GET_ALL)

        AlertFactsModule().run()

        self.mock_ansible_instance.exit_json.assert_called_once_with(
            changed=False, ansible_facts=dict(alerts=ALL_ALERTS))
Esempio n. 2
0
    def test_should_fail_when_get_all_raises_error(self):

        self.mock_ansible_instance.params = copy.deepcopy(PARAMS_GET_ALL)
        self.resource.get_all.side_effect = Exception(ERROR_MSG)

        AlertFactsModule().run()

        self.mock_ansible_instance.fail_json.assert_called_once_with(
            msg=ERROR_MSG)
Esempio n. 3
0
    def test_should_load_config_from_file(self, mock_ansible_module,
                                          mock_ov_client_from_env_vars,
                                          mock_ov_client_from_json_file):
        mock_ov_instance = mock.Mock()
        mock_ov_client_from_json_file.return_value = mock_ov_instance
        mock_ansible_instance = create_ansible_mock({'config': 'config.json'})
        mock_ansible_module.return_value = mock_ansible_instance

        AlertFactsModule()

        mock_ov_client_from_json_file.assert_called_once_with('config.json')
        mock_ov_client_from_env_vars.not_been_called()