Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions app.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@

from chalice import Chalice


# API imports
from chalicelib.api.listings import listings_api
from chalicelib.api.applicants import applicants_api
from chalicelib.api.broadcast import broadcast_api
Expand All @@ -15,6 +17,9 @@
from chalicelib.api.accountability import accountability_api
from chalicelib.api.monitoring import monitoring_api

# Event imports
from chalicelib.events.test import test_events


# Configure and initialize sentry
sentry_sdk.init(
Expand All @@ -33,6 +38,8 @@
)

app = Chalice(app_name="zap")

# Register APIs
app.register_blueprint(broadcast_api)
app.register_blueprint(listings_api)
app.register_blueprint(applicants_api)
Expand All @@ -43,6 +50,9 @@
app.register_blueprint(accountability_api)
app.register_blueprint(monitoring_api)

# Register events
app.register_blueprint(test_events)


@app.route("/")
def index():
Expand Down
File renamed without changes.
10 changes: 10 additions & 0 deletions chalicelib/events/test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
from chalice import Blueprint, Rate
from chalice.app import CloudWatchEvent


test_events = Blueprint(__name__)


@test_events.schedule(Rate(24 * 60, unit=Rate.MINUTES))
def test_event_handler(event: CloudWatchEvent):
return "Test event"
Empty file added tests/events/__init__.py
Empty file.
14 changes: 14 additions & 0 deletions tests/events/test_test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
from chalice.test import Client
from app import app


def test_notify():
with Client(app) as client:
response = client.lambda_.invoke(
"test_event_handler",
client.events.generate_cw_event(
source="", detail_type="", detail="", resources=""
),
)
print(response)
assert response.payload == "Test event"