def test_invalid_stack_object_types_cannot_be_found(self, object_type): # Setup data = SingleAttributeObject(one=42) name = "Foo" stack = Stack() setattr(stack, object_type, {name: data}) ref = Ref(data) dumper = create_refsafe_dumper(stack) # Exercise & Verify with pytest.raises(Exception): ref.as_yaml_node(dumper)
def test_uses_bang_ref_tag_for_yaml_scalar(self): # Setup dumper = create_refsafe_dumper(Mock(Stack)) ref = Ref(ZeroAttributeObject()) # Exercise node = ref.as_yaml_node(dumper) # Verify assert isinstance(node, ScalarNode) assert node.tag == "!Ref"
def test_referred_object_can_be_a_pseudo_parameter(self): # Setup name = "SomeRegion" ref = Ref(AWS_Region) stack = Stack(Resources={name: ref}) dumper = create_refsafe_dumper(stack) # Exercise node = ref.as_yaml_node(dumper) # Verify assert node.value == "AWS::Region"
def test_uses_logical_name_from_stack(self, name): # Setup data = SingleAttributeObject(one=42) stack = Stack(Resources={name: data}) ref = Ref(data) dumper = create_refsafe_dumper(stack) # Exercise node = ref.as_yaml_node(dumper) # Verify assert node.value == name
def test_referred_object_can_be_a_plain_dict(self): # Setup data = dict(bar="hello") name = "Foo" stack = Stack(Resources={name: data}) ref = Ref(data) dumper = create_refsafe_dumper(stack) # Exercise node = ref.as_yaml_node(dumper) # Verify assert node.value == name
def test_all_valid_stack_object_types_can_be_found(self, object_type): # Setup data = SingleAttributeObject(one=42) name = "Foo" stack = Stack() stack[object_type][name] = data ref = Ref(data) dumper = create_refsafe_dumper(stack) # Exercise node = ref.as_yaml_node(dumper) # Verify assert node.value == name