-
Notifications
You must be signed in to change notification settings - Fork 272
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #152 from mttfarmer/python-the-big-fan
The Big Fan Python implementation
- Loading branch information
Showing
8 changed files
with
77 additions
and
24 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import json | ||
import logging | ||
|
||
def handler(event, context): | ||
logger = logging.getLogger(__name__) | ||
logger.setLevel(logging.INFO) | ||
logger.info("request: " + json.dumps(event)) | ||
|
||
records = event["Records"] | ||
|
||
for record in records: | ||
payload = record["body"] | ||
logger.info("received message " + payload) |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import json | ||
import logging | ||
|
||
def handler(event, context): | ||
logger = logging.getLogger(__name__) | ||
logger.setLevel(logging.INFO) | ||
logger.info("request: " + json.dumps(event)) | ||
|
||
records = event["Records"] | ||
|
||
for record in records: | ||
payload = record["body"] | ||
logger.info("received message " + payload) |
Empty file.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
import json | ||
import pytest | ||
|
||
from aws_cdk import core | ||
from the_big_fan.the_big_fan_stack import TheBigFanStack | ||
|
||
#TODO: replace these with aws-cdk/assert(or similar testing framework) if a python implementation is released | ||
def get_template(): | ||
app = core.App() | ||
TheBigFanStack(app, "MyTestStack") | ||
return json.dumps(app.synth().get_stack("MyTestStack").template) | ||
|
||
|
||
def test_sns_topic_created(): | ||
assert("The Big Fan CDK Pattern Topic" in get_template()) | ||
|
||
|
||
def test_statusCreated_subscriber_sqs_created(): | ||
print(get_template()) | ||
assert("BigFanTopicStatusCreatedSubscriberQueue" in get_template()) | ||
|
||
def test_anyOtherStatus_subscriber_sqs_created(): | ||
assert("BigFanTopicAnyOtherStatusSubscriberQueue" in get_template()) | ||
|
||
def test_statusCreated_sns_message_subscription(): | ||
assert('FilterPolicy": {"status": ["created"]}' in get_template()) | ||
|
||
def test_anyOtherStatus_sns_message_subscription(): | ||
assert('"FilterPolicy": {"status": [{"anything-but": ["created"]}]}' in get_template()) | ||
|
||
def test_sqs_receiveMessage_iam_policy_created(): | ||
assert(('"PolicyDocument": {' | ||
'"Statement": [' | ||
'{"Action": [' | ||
'"sqs:ReceiveMessage", ' | ||
'"sqs:ChangeMessageVisibility", ' | ||
'"sqs:GetQueueUrl", ' | ||
'"sqs:DeleteMessage", ' | ||
'"sqs:GetQueueAttributes"], ' | ||
'"Effect": "Allow"') in get_template()) | ||
|
||
def test_createdStatus_sqs_subscriber_lambda_created(): | ||
assert('"Handler": "createdStatus.handler"' in get_template()) | ||
|
||
def test_anyOtherStatus_sqs_subscriber_lambda_created(): | ||
assert('"Handler": "anyOtherStatus.handler"' in get_template()) | ||
|
||
def test_api_gateway_sendEvent_created(): | ||
assert('"PathPart": "SendEvent"' in get_template()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters