Skip to content

Commit

Permalink
Test example (#3)
Browse files Browse the repository at this point in the history
* pytest-watcher

* ignore coverage files

* test handler

* pass test_handler
  • Loading branch information
drernie authored Aug 13, 2024
1 parent 6051c6d commit 27ca99d
Show file tree
Hide file tree
Showing 11 changed files with 119 additions and 316 deletions.
Binary file removed .coverage
Binary file not shown.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,5 @@ dist/
# Environment info
.env
athena_federation/.DS_Store
coverage.xml
.coverage
4 changes: 4 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ update:
test:
poetry run pytest --cov-report xml --cov=athena_federation


watch:
poetry run ptw . --now

# Lint code using flake8
lint:
black .
Expand Down
10 changes: 8 additions & 2 deletions athena_federation/lambda_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,21 @@ def process_event(self, event):
# Populate attributes needed to process the event
self.event = event
self.catalog_name = self.event.get("catalogName")
request_type = self.event.get("@type")
request_type = self.event.get("@type") or "PingRequest"

# TODO: As the event comes in, populate the database name, table name if provided.
# TODO: I can also create new Request types from the event

# Look up the request type, call it dynamically, and return the dictionary representation of it.
# Each model returned implements `as_dict` that returns the info necessary for Athena, including
# specific PyArrow serialization.
return getattr(self, request_type)().as_dict()
print(dir(self))
request_attr = getattr(self, request_type)
if request_attr:
return request_attr().as_dict()
else:
print(f"Unknown request type: {request_type}")
return {}

def PingRequest(self) -> models.PingResponse:
return models.PingResponse(
Expand Down
310 changes: 0 additions & 310 deletions coverage.xml

This file was deleted.

Loading

0 comments on commit 27ca99d

Please sign in to comment.