Skip to content

Commit

Permalink
chore: update directory layout to match for release asset to start br…
Browse files Browse the repository at this point in the history
…eaking up into smaller files
  • Loading branch information
bryantbiggs committed Dec 11, 2021
1 parent 8e57742 commit 84f6a3c
Show file tree
Hide file tree
Showing 15 changed files with 10 additions and 6 deletions.
5 changes: 3 additions & 2 deletions functions/Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ name = "pypi"
[packages]

[dev-packages]
aws_lambda_powertools = "~=1.22"
boto3 = "~=1.20"
botocore = "~=1.23"
black = "*"
Expand All @@ -24,8 +25,8 @@ python_version = "3.8"
test = "python3 -m pytest --cov --cov-report=term"
'test:updatesnapshots' = "python3 -m pytest --snapshot-update"
cover = "python3 -m coverage html"
complexity = "python3 -m radon cc notify_slack.py -a"
halstead = "python3 -m radon hal notify_slack.py"
complexity = "python3 -m radon cc -i 'docs,tests' ."
halstead = "python3 -m radon hal -i 'docs,tests' ."
typecheck = "python3 -m mypy . --ignore-missing-imports"
lint = "python3 -m flake8 . --count --statistics --benchmark --exit-zero --config=.flake8"
'lint:ci' = "python3 -m flake8 . --config=.flake8"
Expand Down
2 changes: 1 addition & 1 deletion functions/notify_slack.py
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,7 @@ def send_slack_notification(payload: Dict[str, Any]) -> str:

@logger.inject_lambda_context(log_event=LOG_EVENTS)
@event_source(data_class=SNSEvent)
def lambda_handler(event: Dict[str, Any], context: Dict[str, Any]) -> str:
def lambda_handler(event: SNSEvent, context: Dict[str, Any]) -> str:
"""
Lambda function to parse notification events and forward to Slack
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
import notify_slack
import pytest

DIRNAME = os.path.dirname(__file__)


def test_sns_get_slack_message_payload_snapshots(snapshot, monkeypatch):
"""
Expand All @@ -27,7 +29,7 @@ def test_sns_get_slack_message_payload_snapshots(snapshot, monkeypatch):

# These are SNS messages that invoke the lambda handler; the event payload is in the
# `message` field
_dir = "./messages"
_dir = os.path.join(DIRNAME, "./messages")
messages = [f for f in os.listdir(_dir) if os.path.isfile(os.path.join(_dir, f))]

for file in messages:
Expand Down Expand Up @@ -64,7 +66,7 @@ def test_event_get_slack_message_payload_snapshots(snapshot, monkeypatch):

# These are just the raw events that will be converted to JSON string and
# sent via SNS message
_dir = "./events"
_dir = os.path.join(DIRNAME, "./events")
events = [f for f in os.listdir(_dir) if os.path.isfile(os.path.join(_dir, f))]

for file in events:
Expand Down Expand Up @@ -92,7 +94,8 @@ def test_environment_variables_set(monkeypatch):
"SLACK_WEBHOOK_URL", "https://hooks.slack.com/services/YOUR/WEBOOK/URL"
)

with open(os.path.join("./messages/text_message.json"), "r") as efile:
text_message = os.path.join(os.path.join(DIRNAME, "./messages/text_message.json"))
with open(text_message, "r") as efile:
event = ast.literal_eval(efile.read())

for record in event["Records"]:
Expand Down
File renamed without changes.

0 comments on commit 84f6a3c

Please sign in to comment.