Skip to content

Commit

Permalink
tests: migrate for aws nodes; linked to online documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
tsypuk committed Aug 6, 2023
1 parent 08af4bc commit 75f55e3
Show file tree
Hide file tree
Showing 11 changed files with 213 additions and 207 deletions.
23 changes: 13 additions & 10 deletions docs/docs/aws-components/dynamo.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,22 @@
layout: default
title: DynamoDB
parent: AWS Components
nav_order: 4
nav_order: 2
---

# DynamoDB
{: .d-inline-block }

Tables are responsive by default, allowing wide tables to have a horizontal scroll to access columns outside of the normal viewport.
New (v0.2.0)
{: .label .label-green }

## Code Snippet:

```python
{% root_include ../tests/aws/test_dynamo.py 9:20 %}
```

## Rendering:

<div class="code-example" markdown="1">

Expand All @@ -18,12 +28,5 @@ Tables are responsive by default, allowing wide tables to have a horizontal scro
| ok | good `oreos` | hmm |
| ok | good `zoute` drop | yumm |

TODO: add image here
</div>
```markdown
| head1 | head two | three |
|:-------------|:------------------|:------|
| ok | good swedish fish | nice |
| out of stock | good and plenty | nice |
| ok | good `oreos` | hmm |
| ok | good `zoute` drop | yumm |
```
12 changes: 10 additions & 2 deletions docs/docs/aws-components/lambda.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,23 @@
layout: default
title: Lambda Function
parent: AWS Components
nav_order: 7
nav_order: 1
---

# Lambda Function
{: .d-inline-block }

New (v0.4.0)
New (v0.2.0)
{: .label .label-green }

## Code Snippet:

```python
{% root_include ../tests/aws/test_lambda.py 9:25 %}
```

## Rendering:

Markdown does not include support for callouts. However, you can style text as a callout using a Markdown extension supported by kramdown: [*block IALs*](https://kramdown.gettalong.org/quickref.html#block-attributes).

Common kinds of callouts include `highlight`, `important`, `new`, `note`, and `warning`.
Expand Down
32 changes: 32 additions & 0 deletions docs/docs/aws-components/sns.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
---
layout: default
title: SNS (Simple Notification Service)
parent: AWS Components
nav_order: 4
---

# SNS (Simple Notification Service)
{: .d-inline-block }

New (v0.2.0)
{: .label .label-green }

## Code Snippet:

```python
{% root_include ../tests/aws/test_sns.py 9:19 %}
```

## Rendering:

<div class="code-example" markdown="1">

| head1 | head two | three |
|:-------------|:------------------|:------|
| ok | good swedish fish | nice |
| out of stock | good and plenty | nice |
| ok | good `oreos` | hmm |
| ok | good `zoute` drop | yumm |

TODO: add image here
</div>
97 changes: 17 additions & 80 deletions docs/docs/aws-components/sqs.md
Original file line number Diff line number Diff line change
@@ -1,95 +1,32 @@
---
layout: default
title: SQS
title: SQS (Simple Queue Service)
parent: AWS Components
nav_order: 2
nav_order: 3
---

# SQS
{: .no_toc }
# SQS (Simple Queue Service)
{: .d-inline-block }

## Table of contents
{: .no_toc .text-delta }
New (v0.2.0)
{: .label .label-green }

1. TOC
{:toc}
## Code Snippet:

---

## Basic button styles

### Links that look like buttons

<div class="code-example" markdown="1">
[Link button](http://example.com/){: .btn }

[Link button](http://example.com/){: .btn .btn-purple }
[Link button](http://example.com/){: .btn .btn-blue }
[Link button](http://example.com/){: .btn .btn-green }

[Link button](http://example.com/){: .btn .btn-outline }
</div>
```markdown
[Link button](http://example.com/){: .btn }

[Link button](http://example.com/){: .btn .btn-purple }
[Link button](http://example.com/){: .btn .btn-blue }
[Link button](http://example.com/){: .btn .btn-green }

[Link button](http://example.com/){: .btn .btn-outline }
```

### Button element

GitHub Flavored Markdown does not support the `button` element, so you'll have to use inline HTML for this:

<div class="code-example">
<button type="button" name="button" class="btn">Button element</button>
</div>
```html
<button type="button" name="button" class="btn">Button element</button>
```python
{% root_include ../tests/aws/test_sqs.py 9:21 %}
```

---

## Using utilities with buttons

### Button size

## Rendering:

<div class="code-example" markdown="1">
<span class="fs-6">
[Big ass button](http://example.com/){: .btn }
</span>

<span class="fs-3">
[Tiny ass button](http://example.com/){: .btn }
</span>
</div>
```markdown
<span class="fs-8">
[Link button](http://example.com/){: .btn }
</span>

<span class="fs-3">
[Tiny ass button](http://example.com/){: .btn }
</span>
```

### Spacing between buttons
| head1 | head two | three |
|:-------------|:------------------|:------|
| ok | good swedish fish | nice |
| out of stock | good and plenty | nice |
| ok | good `oreos` | hmm |
| ok | good `zoute` drop | yumm |


<div class="code-example" markdown="1">
[Button with space](http://example.com/){: .btn .btn-purple .mr-2 }
[Button](http://example.com/){: .btn .btn-blue }

[Button with more space](http://example.com/){: .btn .btn-green .mr-4 }
[Button](http://example.com/){: .btn .btn-blue }
TODO: add image here
</div>
```markdown
[Button with space](http://example.com/){: .btn .btn-purple .mr-2 }
[Button](http://example.com/){: .btn .btn-blue }

[Button with more space](http://example.com/){: .btn .btn-green .mr-4 }
[Button](http://example.com/){: .btn .btn-blue }
```
10 changes: 9 additions & 1 deletion docs/docs/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@ Compatibility tests are included for latest LTS Python versions that have ``Secu
| 3.8 | 14 Oct 2019 | 14 Oct 2024 | 3.8.17 |
| 3.7 | 26 Jun 2018 | 27 Jun 2023 | 3.7.17 |

You can use ``multicloud-diagrams`` with Python versions <3.7 that do not have official ``Security Support`` with own verification.
{: .highlight }
You can use ``multicloud-diagrams`` with ``Python`` versions ``<3.7`` that do not have official ``Security Support`` with your own verification.

The package is readily accessible on [PyPI: https://pypi.org/project/multicloud-diagrams/](https://pypi.org/project/multicloud-diagrams/)
for easy installation and usage. As an open-source project, it encourages community participation and welcomes contributions from developers
Expand Down Expand Up @@ -110,7 +111,9 @@ mcd.export_to_file(output_file)
Considering that we haven't specified the coordinates or distribution algorithm yet (which will be detailed in the next instructions), by default, all elements will be placed in the left-top corner.
We have the flexibility to move and position them according to our preferences.

<div class="code-example" markdown="1">
![IAM add Role and Lambda](images/open-iam.gif)
</div>

## Reuse coordinates from previous diagram version

Expand Down Expand Up @@ -159,15 +162,20 @@ mcd.export_to_file('../output/diagram_v2.drawio')

This approach allows for efficient placement of new elements while preserving the layout of existing ones based on the previous diagram's coordinates.

<div class="code-example" markdown="1">
![IAM add Permissions](images/iam-add-permissions.gif)
</div>

By leveraging this feature, we can implement versioning effectively by consistently reading coordinates from the previous file,
which includes a timestamp (e.g., ``datetime`` in the file name). Subsequently, we write the updated elements to a new file.
This functionality proves invaluable for tracking historical records and facilitating a comprehensive comparison of infrastructure evolution over time.

## Arrange Layout automatic positioning

<div class="code-example" markdown="1">
![IAM add Permissions](images/arrange-layout.gif)
</div>

{: .highlight }
For more advanced use cases, detailed customization options, and in-depth functionalities, please continue exploring the next sections in our documentation. There, you will find a wealth of
information to help you leverage the full potential of multicloud-diagrams in your projects. Happy diagramming!
4 changes: 2 additions & 2 deletions docs/docs/extra.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
---
layout: default
title: drawio usage
title: DRAWIO How-To
nav_order: 4
---

# How to use drawio
# DRAWIO How To
{: .no_toc }

Draw.io has gained widespread popularity as an extensively used editor and file format. Apart from the standard web browser version, it offers various other scenarios for usage, which include:
Expand Down
31 changes: 31 additions & 0 deletions tests/aws/test_dynamo.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
from multicloud_diagrams import MultiCloudDiagrams

from utils.utils import TestUtilities
# NOTE!!! Content of this file is mapped to documentation with lines position

class TestAWSVertexInIsolation(TestUtilities):

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

# when
table_arn = 'arn:aws:dynamodb:eu-west-1:123456789012:table/prod-dynamo-table'
table_name = 'prod-dynamo-table'
metadata = {
'DeletionProtectionEnabled': True,
'ItemCount': 900,
'TableSizeBytes': 123
}
mcd.add_vertex(node_id=table_arn, node_name=table_name, arn=table_arn, node_type='dynamo', metadata=metadata)

# then
expected = {
'id': 'vertex:dynamo:arn:aws:dynamodb:eu-west-1:123456789012:table/prod-dynamo-table',
'value': ('<b>Name</b>: prod-dynamo-table<BR><b>ARN</b>: arn:aws:dynamodb:eu-west-1:123456789012:table/prod-dynamo-table'
'<BR>-----------<BR>'
'<b>DeletionProtectionEnabled</b>: True<BR><b>ItemCount</b>: 900<BR><b>TableSizeBytes</b>: 123'),
'parent': '1',
'vertex': '1'
}
self.verify_aws_resource(expected, mcd.mx_file, 'prod-dynamo-table', 'dynamo')
37 changes: 37 additions & 0 deletions tests/aws/test_lambda.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
from multicloud_diagrams import MultiCloudDiagrams

from utils.utils import TestUtilities
# NOTE!!! Content of this file is mapped to documentation with lines position

class TestAWSVertexInIsolation(TestUtilities):

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

# when
func_arn = 'arn:aws:lambda:eu-west-1:123456789012:function:producer-lambda'
metadata = {
"CodeSize": 1234,
"Handler": "main",
"Layers": 0,
"Memory": 128,
"PackageType": "Zip",
"Runtime": "go1.x",
"Timeout": 30,
"TracingConfig": "{'Mode': 'Active'}",
"Version": "$LATEST"
}
mcd.add_vertex(node_id=func_arn, node_name='producer-lambda', arn=func_arn, node_type='lambda_function', metadata=metadata)

# then
expected = {
'id': 'vertex:lambda_function:arn:aws:lambda:eu-west-1:123456789012:function:producer-lambda',
'value': "<b>Name</b>: producer-lambda<BR><b>ARN</b>: arn:aws:lambda:eu-west-1:123456789012:function:producer-lambda"
"<BR>-----------<BR>"
"<b>CodeSize</b>: 1234<BR><b>Handler</b>: main<BR><b>Layers</b>: 0<BR><b>Memory</b>: 128<BR><b>PackageType</b>: Zip<BR>"
"<b>Runtime</b>: go1.x<BR><b>Timeout</b>: 30<BR><b>TracingConfig</b>: {'Mode': 'Active'}<BR><b>Version</b>: $LATEST",
'parent': '1',
'vertex': '1'
}
self.verify_aws_resource(expected, mcd.mx_file, 'producer-lambda', 'lambda_function')
30 changes: 30 additions & 0 deletions tests/aws/test_sns.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
from multicloud_diagrams import MultiCloudDiagrams

from utils.utils import TestUtilities
# NOTE!!! Content of this file is mapped to documentation with lines position

class TestAWSVertexInIsolation(TestUtilities):

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(node_id=sns_arn, node_name='internal.fifo', arn=sns_arn, node_type='sns', metadata=metadata)

# then
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',
'parent': '1',
'vertex': '1'
}
self.verify_aws_resource(expected, mcd.mx_file, 'internal.fifo', 'sns')
32 changes: 32 additions & 0 deletions tests/aws/test_sqs.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
from multicloud_diagrams import MultiCloudDiagrams

from utils.utils import TestUtilities
# NOTE!!! Content of this file is mapped to documentation with lines position

class TestAWSVertexInIsolation(TestUtilities):

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

# when
sqs_arn = 'arn:aws:sqs:eu-west-1:123456789012:int-eu-live-events.fifo'
metadata = {
"DelaySeconds": 0,
"FifoQueue": "TRUE",
"ReceiveMessageWaitTimeSeconds": 0,
"SqsManagedSseEnabled": "false",
"VisibilityTimeout": 30
}
mcd.add_vertex(node_id=sqs_arn, node_name='int-eu-live-events.fifo', arn=sqs_arn, node_type='sqs', metadata=metadata)

# then
expected = {
'id': 'vertex:sqs:arn:aws:sqs:eu-west-1:123456789012:int-eu-live-events.fifo',
'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',
'parent': '1',
'vertex': '1'
}
self.verify_aws_resource(expected, mcd.mx_file, 'int-eu-live-events.fifo', 'sqs')

0 comments on commit 75f55e3

Please sign in to comment.