Skip to content

Commit

Permalink
tests: added sns vertex verification
Browse files Browse the repository at this point in the history
  • Loading branch information
tsypuk committed Jul 27, 2023
1 parent 03ecea8 commit 8be56a5
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 6 deletions.
39 changes: 34 additions & 5 deletions tests/test_aws_vertecies.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from utils.utils import TestUtilities


class TestMultiCloudDiagramsAWSVertecies(TestUtilities):
class Test_MCD_AWS_Vertex_Isolation(TestUtilities):

def test_dynamo(self):
# given
Expand All @@ -26,7 +26,7 @@ def test_dynamo(self):
self.verify_mxfile_default(et.ElementTree(tree))

mx_cells = tree.findall("./*/*/*/")
self.verify_vertex_added_in_isolation(mx_cells)
self.verify_vertex_in_isolation(mx_cells)

expected = {
'id': 'vertex:dynamo:arn:aws:dynamodb:eu-west-1:123456789012:table/prod-dynamo-table',
Expand All @@ -50,21 +50,50 @@ def test_sqs(self):
"SqsManagedSseEnabled": "false",
"VisibilityTimeout": 30
}
mcd.add_vertex(id=sqs_arn, node_name='events', arn=sqs_arn, node_type='sqs', metadata=metadata)
mcd.add_vertex(id=sqs_arn, node_name='int-eu-live-events.fifo', arn=sqs_arn, node_type='sqs', metadata=metadata)

# then
tree = et.ElementTree(mcd.mxfile)
self.verify_mxfile_default(et.ElementTree(tree))

mx_cells = tree.findall("./*/*/*/")
self.verify_vertex_added_in_isolation(mx_cells)
self.verify_vertex_in_isolation(mx_cells)

expected = {
'id': 'vertex:sqs:arn:aws:sqs:eu-west-1:123456789012:int-eu-live-events.fifo',
'value': '<b>Name</b>: events<BR><b>ARN</b>: arn:aws:sqs:eu-west-1:123456789012:int-eu-live-events.fifo <BR>-----------<BR><b>DelaySeconds</b>: 0<BR><b>FifoQueue</b>: TRUE<BR><b>ReceiveMessageWaitTimeSeconds</b>: 0<BR><b>SqsManagedSseEnabled</b>: false<BR><b>VisibilityTimeout</b>: 30',
'value': '<b>Name</b>: int-eu-live-events.fifo<BR><b>ARN</b>: arn:aws:sqs:eu-west-1:123456789012:int-eu-live-events.fifo <BR>-----------<BR><b>DelaySeconds</b>: 0<BR><b>FifoQueue</b>: TRUE<BR><b>ReceiveMessageWaitTimeSeconds</b>: 0<BR><b>SqsManagedSseEnabled</b>: false<BR><b>VisibilityTimeout</b>: 30',
'style': 'verticalLabelPosition=bottom;html=1;verticalAlign=top;aspect=fixed;align=left;pointerEvents=1;shape=mxgraph.aws4.resourceIcon;resIcon=mxgraph.aws4.sqs;fillColor=#F58534;gradientColor=#FF4F8B;gradientDirection=north;fillColor=#BC1356;strokeColor=#ffffff;dashed=0;verticalLabelPosition=bottom',
'parent': '1',
'vertex': '1'
}
self.verify_mx_cell(mx_cells[2], expected)

def test_sns(self):
# given
mcd = MultiCloudDiagrams()

# when
sns_arn = 'arn:aws:sns:eu-west-1:123456789012:internal.fifo'
metadata = {
"Owner": 123456789012,
"SubscriptionsConfirmed": 3,
"SubscriptionsPending": 0
}
mcd.add_vertex(id=sns_arn, node_name='internal.fifo', arn=sns_arn, node_type='sns', metadata=metadata)

# then
tree = et.ElementTree(mcd.mxfile)
self.verify_mxfile_default(et.ElementTree(tree))

mx_cells = tree.findall("./*/*/*/")
self.verify_vertex_in_isolation(mx_cells)

expected = {
'id': 'vertex:sns:arn:aws:sns:eu-west-1:123456789012:internal.fifo',
'value': '<b>Name</b>: internal.fifo<BR><b>ARN</b>: arn:aws:sns:eu-west-1:123456789012:internal.fifo <BR>-----------<BR><b>Owner</b>: 123456789012<BR><b>SubscriptionsConfirmed</b>: 3<BR><b>SubscriptionsPending</b>: 0',
'style': 'verticalLabelPosition=bottom;html=1;verticalAlign=top;aspect=fixed;align=left;pointerEvents=1;sketch=0;outlineConnect=0;fontColor=#232F3E;gradientColor=#FF4F8B;gradientDirection=north;fillColor=#BC1356;strokeColor=#ffffff;dashed=0;verticalLabelPosition=bottom;verticalAlign=top;align=left;html=1;fontSize=12;fontStyle=0;aspect=fixed;shape=mxgraph.aws4.resourceIcon;resIcon=mxgraph.aws4.sns;',
'parent': '1',
'vertex': '1'
}
self.verify_mx_cell(mx_cells[2], expected)

2 changes: 1 addition & 1 deletion utils/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ def verify_mxfile_default(self, tree):
self.verify_mx_graph_models(tree.findall("/*/"))
self.verify_roots(tree.findall("./*/*/"))

def verify_vertex_added_in_isolation(self, mx_cells):
def verify_vertex_in_isolation(self, mx_cells):
self.assertEqual(3, len(mx_cells))
self.verify_mx_cell(mx_cells[0], expected={'id': '0'})
self.verify_mx_cell(mx_cells[1], expected={'id': '1', 'parent': '0'})

0 comments on commit 8be56a5

Please sign in to comment.