Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_resources_filtered_by_type():
generic_resource = {"Logical ID": {"Type": "Resource type", "Properties": {"foo": "bar"}}}
user = {"User": IAMUser()}
model = CFModel(Resources={**generic_resource, **user})
assert model.resources_filtered_by_type(("Resource type",)) == generic_resource
assert model.resources_filtered_by_type(("Resource type", IAMUser)) == {**generic_resource, **user}
assert model.resources_filtered_by_type((IAMUser,)) == user
def model():
return CFModel(
**{
"AWSTemplateFormatVersion": "2012-12-12",
"Description": "JSON string",
"Metadata": {},
"Parameters": {},
"Mappings": {},
"Conditions": {},
"Transform": [],
"Resources": {"Logical ID": {"Type": "Resource type", "Properties": {"foo": "bar"}}},
"Rules": {},
"Outputs": {},
}
if self.Conditions:
conditions = dict_value.pop("Conditions")
else:
conditions = {}
resolved_conditions = {
key: _extended_bool(resolve(value, extended_parameters, self.Mappings, {}))
for key, value in conditions.items()
}
resources = dict_value.pop("Resources")
resolved_resources = {
key: resolve(value, extended_parameters, self.Mappings, resolved_conditions)
for key, value in resources.items()
}
return CFModel(**dict_value, Conditions=resolved_conditions, Resources=resolved_resources)
def parse(template):
return CFModel(**template)