Skip to content

Commit

Permalink
Fix graph testing
Browse files Browse the repository at this point in the history
  • Loading branch information
kddejong committed Jul 16, 2024
1 parent 5e765d5 commit 33432ae
Showing 1 changed file with 28 additions and 3 deletions.
31 changes: 28 additions & 3 deletions test/unit/module/template/test_template.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

import json
import os
import sys
from test.testlib.testcase import BaseTestCase
from unittest.mock import patch

Expand Down Expand Up @@ -40,7 +41,31 @@ def test_build_graph(self):
dot = "test/fixtures/templates/good/generic.yaml.dot"

# ruff: noqa: E501
expected_content = """digraph "template" {
if sys.version_info >= (3, 10):
expected_content = """digraph "template" {
MyModule [label="MyModule\\n<My::Organization::Custom::MODULE>", color=black, shape=ellipse, type=Resource];
RootRole [label="RootRole\\n<AWS::IAM::Role>", color=black, shape=ellipse, type=Resource];
RolePolicies [label="RolePolicies\\n<AWS::IAM::Policy>", color=black, shape=ellipse, type=Resource];
RootInstanceProfile [label="RootInstanceProfile\\n<AWS::IAM::InstanceProfile>", color=black, shape=ellipse, type=Resource];
MyEC2Instance [label="MyEC2Instance\\n<AWS::EC2::Instance>", color=black, shape=ellipse, type=Resource];
mySnsTopic [label="mySnsTopic\\n<AWS::SNS::Topic>", color=black, shape=ellipse, type=Resource];
MyEC2Instance1 [label="MyEC2Instance1\\n<AWS::EC2::Instance>", color=black, shape=ellipse, type=Resource];
ElasticIP [label="ElasticIP\\n<AWS::EC2::EIP>", color=black, shape=ellipse, type=Resource];
ElasticLoadBalancer [label="ElasticLoadBalancer\\n<AWS::ElasticLoadBalancing::LoadBalancer>", color=black, shape=ellipse, type=Resource];
IamPipeline [label="IamPipeline\\n<AWS::CloudFormation::Stack>", color=black, shape=ellipse, type=Resource];
CustomResource [label="CustomResource\\n<Custom::Function>", color=black, shape=ellipse, type=Resource];
WaitCondition [label="WaitCondition\\n<AWS::CloudFormation::WaitCondition>", color=black, shape=ellipse, type=Resource];
LambdaFunction [label="LambdaFunction\\n<AWS::Lambda::Function>", color=black, shape=ellipse, type=Resource];
RolePolicies -> RootRole [key=0, source_paths="['Properties', 'Roles', 0]", label=Ref, color=black];
RootInstanceProfile -> RootRole [key=0, source_paths="['Properties', 'Roles', 0]", label=Ref, color=black];
MyEC2Instance -> RootInstanceProfile [key=0, source_paths="['Properties', 'IamInstanceProfile']", label=Ref, color=black];
ElasticLoadBalancer -> MyEC2Instance [key=0, source_paths="['Properties', 'Instances', 0]", label=Ref, color=black];
}
""".split(
"\n"
)
else:
expected_content = """digraph "template" {
MyModule [color=black, label="MyModule\\n<My::Organization::Custom::MODULE>", shape=ellipse, type=Resource];
RootRole [color=black, label="RootRole\\n<AWS::IAM::Role>", shape=ellipse, type=Resource];
RolePolicies [color=black, label="RolePolicies\\n<AWS::IAM::Policy>", shape=ellipse, type=Resource];
Expand All @@ -60,8 +85,8 @@ def test_build_graph(self):
ElasticLoadBalancer -> MyEC2Instance [color=black, key=0, label=Ref, source_paths="['Properties', 'Instances', 0]"];
}
""".split(
"\n"
)
"\n"
)

assert os.path.exists(dot)
with open(dot, "r") as file:
Expand Down

0 comments on commit 33432ae

Please sign in to comment.