Search code examples
python-3.xunit-testingaws-lambdaamazon-athenamoto

How to unit test aws athena sql queries in python lambda?


I have a python lambda that will call an SQL query to Athena for pulling certain data for my lambda calculation. How do I unit test Athena queries in the lambda? As lambda uses some other services I used MOTO to mock services.


Solution

  • I think you can write an unit test code locally as long as the business logic is separated from lambda specific code like even and context. Here is an example.

    Unfortunately, moto has not supported Athena yet. You can make an issue to request a new feature with your use cases or you can make new pull request. Anyway the community would help you. GitHub - moto