Search code examples
pythonboto3amazon-athenamoto

AWS Athena with python - is it possible to mock with moto while still testing the sql?


My code performs sql queries on Athena using boto3.

I want to be able to test the entire functionality, but avoiding the actual access to athena. I need the data to be fetched based on the query string my code sends and the actual data I put in mocked s3 as part of the tests setup.

Has anyone ever done something like this?

All examples I see online are not really testing sql logic, but rather use predefined query results to be returned when starting Athena queries.


Solution

  • Moto maintainer here - no, it is not possible to test the actual queries, as it doesn't have an SQL engine behind it.

    You could look into using Localstack instead - their Pro offering has support for Athena, and does actually execute SQL queries.