예제 #1
0
    def test_failure(self, mocker):
        get_mock = mocker.patch.object(utils, "get")
        get_mock.side_effect = errors.Error("Bad error")
        set_module_args(name="sample-check")

        with pytest.raises(AnsibleFailJson):
            check_info.main()
예제 #2
0
    def test_missing_single_check(self, mocker):
        get_mock = mocker.patch.object(utils, "get")
        get_mock.return_value = None
        set_module_args(name="sample-check")

        with pytest.raises(AnsibleExitJson) as context:
            check_info.main()

        assert context.value.args[0]["objects"] == []
예제 #3
0
    def test_get_single_check(self, mocker):
        get_mock = mocker.patch.object(utils, "get")
        get_mock.return_value = 4
        set_module_args(name="sample-check")

        with pytest.raises(AnsibleExitJson) as context:
            check_info.main()

        _client, path = get_mock.call_args[0]
        assert path == "/checks/sample-check"
        assert context.value.args[0]["objects"] == [4]
예제 #4
0
    def test_get_all_checks(self, mocker):
        get_mock = mocker.patch.object(utils, "get")
        get_mock.return_value = [1, 2, 3]
        set_module_args()

        with pytest.raises(AnsibleExitJson) as context:
            check_info.main()

        _client, path = get_mock.call_args[0]
        assert path == "/checks"
        assert context.value.args[0]["objects"] == [1, 2, 3]