예제 #1
0
    def test_failure(self, mocker):
        sync_mock = mocker.patch.object(utils, "sync")
        sync_mock.side_effect = errors.Error("Bad error")
        set_module_args(name='test_handler',
                        state='absent',
                        handlers=['tcp_handler', 'udp_handler'])

        with pytest.raises(AnsibleFailJson):
            handler_set.main()
예제 #2
0
    def test_all_handler_set_parameters(self, mocker):
        sync_mock = mocker.patch.object(utils, "sync")
        sync_mock.return_value = True, {}
        set_module_args(name='test_handler',
                        state='absent',
                        handlers=['tcp_handler', 'udp_handler'])

        with pytest.raises(AnsibleExitJson):
            handler_set.main()

        state, _client, path, payload, check_mode = sync_mock.call_args[0]
        assert state == "absent"
        assert path == "/handlers/test_handler"
        assert payload == dict(
            type='set',
            handlers=['tcp_handler', 'udp_handler'],
            metadata=dict(
                name="test_handler",
                namespace="default",
            ),
        )
        assert check_mode is False