File size: 1,637 Bytes
26e6f31
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
"""
Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
SPDX-License-Identifier: MIT-0
"""

from __future__ import annotations

from collections import deque

import pytest

from cfnlint.context import Path, create_context_for_template
from cfnlint.helpers import FUNCTIONS
from cfnlint.jsonschema import CfnTemplateValidator
from cfnlint.template import Template


@pytest.fixture
def template(request):
    if hasattr(request, "param"):
        return request.param
    return {}


@pytest.fixture
def regions():
    return ["us-east-1"]


@pytest.fixture
def cfn(template, regions):
    return Template(
        "",
        template,
        regions,
    )


@pytest.fixture
def path(request):
    if hasattr(request, "param"):
        t_path = deque(request.param.get("path", []))
        value_path = deque(request.param.get("value_path", []))
        cfn_path = deque(request.param.get("cfn_path", []))

        return Path(
            path=t_path,
            value_path=value_path,
            cfn_path=cfn_path,
        )

    return Path(
        path=deque(),
        value_path=deque(),
        cfn_path=deque(),
    )


@pytest.fixture
def functions():
    return FUNCTIONS


@pytest.fixture
def strict_types(strict_types=True):
    return strict_types


@pytest.fixture
def context(cfn, path, functions, strict_types):
    return create_context_for_template(cfn).evolve(
        path=path,
        functions=functions,
        strict_types=strict_types,
    )


@pytest.fixture
def validator(cfn, context):
    return CfnTemplateValidator(
        context=context,
        cfn=cfn,
        schema={},
    )