Skip to content

Commit

Permalink
Fix testing and file format
Browse files Browse the repository at this point in the history
  • Loading branch information
kddejong committed May 17, 2024
1 parent b831f43 commit 232c7ad
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@
"const": "PROVISIONED"
}
},
"required": ["BillingMode"]
"required": [
"BillingMode"
]
},
"then": {
"required": [
Expand Down
3 changes: 2 additions & 1 deletion test/integration/test_schema_files.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ class TestSchemaFiles(TestCase):
_found_keywords: List[str] = [
"Resources/*",
"Parameters/*",
"Resources/*/DependsOn",
"Resources/*/DependsOn/*",
]

def setUp(self) -> None:
Expand Down Expand Up @@ -102,7 +104,6 @@ def _build_keywords(self, obj: Any, spec: Any, refs: list[str] | None = None):
if "array" in ensure_list(obj["type"]):
if "items" in obj:
for item in self._build_keywords(obj["items"], spec, refs):
print(obj["items"])
yield ["*"] + item

if "$ref" in obj:
Expand Down
12 changes: 12 additions & 0 deletions test/unit/rules/resources/test_dependson.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,3 +141,15 @@ def test_validate(name, instance, path, expected, rule, validator):
errs = list(rule.validate(validator, False, instance, {}))

assert errs == expected, f"Test {name!r} got {errs!r}"


def test_validate_with_no_cfn(rule, validator):
validator = validator.evolve(
context=validator.context.evolve(
path=Path(path=deque(["Resources", "ChildBucket", "DependsOn"]))
)
)
validator.cfn = None
errs = list(rule.validate(validator, False, "ParentBucketWithBadCondition", {}))

assert errs == [], f"Test without cfn got {errs!r}"
11 changes: 11 additions & 0 deletions test/unit/rules/resources/test_retentionperiod.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,3 +85,14 @@ def test_validate(name, instance, expected, rule, validator):
# we use error counts in this one as the instance types are
# always changing so we aren't going to hold ourselves up by that
assert errors == expected, f"Test {name!r} got {errors!r}"


def test_validate_with_no_path(rule, validator):
validator = validator.evolve(
context=validator.context.path.evolve(
path=Path(path=deque([]), cfn_path=deque([]))
)
)

errors = list(rule.validate(validator, False, {}, {}))
assert errors == []

0 comments on commit 232c7ad

Please sign in to comment.