From 5c6bbe2960a7b7f0fb5789c087b514978cae6e5c Mon Sep 17 00:00:00 2001 From: Mark van Holsteijn Date: Fri, 23 Feb 2024 15:45:50 +0100 Subject: [PATCH] feat: add test for read_template --- tests/test_add_new_resources.py | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/tests/test_add_new_resources.py b/tests/test_add_new_resources.py index 54a891d..3f87e79 100644 --- a/tests/test_add_new_resources.py +++ b/tests/test_add_new_resources.py @@ -1,8 +1,10 @@ -from aws_cfn_update.rest_api_body_updater import RestAPIBodyUpdater -import json +import pathlib +import tempfile + +from ruamel.yaml import YAML from aws_cfn_update.add_missing_resources import add_missing_resources -from aws_cfn_update.cfn_updater import CfnUpdater +from aws_cfn_update.cfn_updater import read_template def test_simple(): @@ -35,3 +37,14 @@ def test_add_no_outputs(): result = add_missing_resources(target, source) assert target["Resources"].get("EC2Instance") assert not target.get("Outputs") + + +def test_read_template(): + source = { + "Resources": {"AMI": {}, "EC2Instance": {"ImageId": {"Ref": "AMI"}}}, + "Outputs": {"XXX": {"Value": "bla"}}, + } + with tempfile.NamedTemporaryFile(suffix=".yaml") as f: + YAML(typ="safe").dump(source, pathlib.Path(f.name)) + result = read_template(f.name) + assert source == result