Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add class template #24

Merged
merged 2 commits into from
Nov 29, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions src/cloudformation.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,3 +86,12 @@ def find_nodes(tree: Dict[str, Any], node_type: NodeType) -> List[Dict[str, Any]
nodes.append({id_: properties})

return nodes


class Template:
def __init__(self, template: Optional[str] = None) -> None:
self._cloudformation = load(template)
gabriel-f-santos marked this conversation as resolved.
Show resolved Hide resolved

@property
def cloudformation(self):
return self._cloudformation
9 changes: 9 additions & 0 deletions tests/test_cloudformation.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,3 +111,12 @@ def test_find_nodes(self):
]

self.assertEqual(nodes, expected_nodes)


class TestTemplate(unittest.TestCase):
def test_instantiate_template(self):
path_template = "tests/fixtures/templates/example1.yml"
template = cf.Template(path_template)
content = template.cloudformation

self.assertIsInstance(content, dict)
gabriel-f-santos marked this conversation as resolved.
Show resolved Hide resolved