This is an automated email from the ASF dual-hosted git repository.
potiuk pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/airflow.git
The following commit(s) were added to refs/heads/main by this push:
new ab34a9babe5 Mock AWS during Athena tests (#54576)
ab34a9babe5 is described below
commit ab34a9babe5c1457691182a6467673605b8ac492
Author: Jarek Potiuk <[email protected]>
AuthorDate: Sat Aug 16 22:23:36 2025 +0200
Mock AWS during Athena tests (#54576)
The Athena tests were actually connecting to AWS during the run, but
it should not be necessary at all. We are mocking AWS tests so that
the calls to AWS apis are handled locally with moto.
---
providers/amazon/tests/unit/amazon/aws/hooks/test_athena.py | 4 +++-
providers/amazon/tests/unit/amazon/aws/operators/test_athena.py | 3 +++
providers/amazon/tests/unit/amazon/aws/sensors/test_athena.py | 4 +++-
3 files changed, 9 insertions(+), 2 deletions(-)
diff --git a/providers/amazon/tests/unit/amazon/aws/hooks/test_athena.py
b/providers/amazon/tests/unit/amazon/aws/hooks/test_athena.py
index 5e75cf3d09b..ebc141c026d 100644
--- a/providers/amazon/tests/unit/amazon/aws/hooks/test_athena.py
+++ b/providers/amazon/tests/unit/amazon/aws/hooks/test_athena.py
@@ -19,6 +19,7 @@ from __future__ import annotations
from unittest import mock
import pytest
+from moto import mock_aws
from airflow.providers.amazon.aws.hooks.athena import (
MULTI_LINE_QUERY_LOG_PREFIX,
@@ -58,8 +59,9 @@ MOCK_QUERY_EXECUTION_OUTPUT = {
}
+@mock_aws
class TestAthenaHook:
- def setup_method(self):
+ def setup_method(self, _):
self.athena = AthenaHook()
def test_init(self):
diff --git a/providers/amazon/tests/unit/amazon/aws/operators/test_athena.py
b/providers/amazon/tests/unit/amazon/aws/operators/test_athena.py
index dc3ad6e12c0..721db41d036 100644
--- a/providers/amazon/tests/unit/amazon/aws/operators/test_athena.py
+++ b/providers/amazon/tests/unit/amazon/aws/operators/test_athena.py
@@ -43,6 +43,8 @@ try:
from airflow.sdk import timezone
except ImportError:
from airflow.utils import timezone # type: ignore[attr-defined,no-redef]
+from moto import mock_aws
+
from airflow.utils.state import DagRunState
from airflow.utils.types import DagRunType
@@ -67,6 +69,7 @@ query_context = {"Database": MOCK_DATA["database"],
"Catalog": MOCK_DATA["catalo
result_configuration = {"OutputLocation": MOCK_DATA["outputLocation"]}
+@mock_aws
class TestAthenaOperator:
@pytest.fixture(autouse=True)
def _setup_test_cases(self):
diff --git a/providers/amazon/tests/unit/amazon/aws/sensors/test_athena.py
b/providers/amazon/tests/unit/amazon/aws/sensors/test_athena.py
index c770ab7dde3..e2dd2289ece 100644
--- a/providers/amazon/tests/unit/amazon/aws/sensors/test_athena.py
+++ b/providers/amazon/tests/unit/amazon/aws/sensors/test_athena.py
@@ -20,6 +20,7 @@ from __future__ import annotations
from unittest import mock
import pytest
+from moto import mock_aws
from airflow.exceptions import AirflowException
from airflow.providers.amazon.aws.hooks.athena import AthenaHook
@@ -32,8 +33,9 @@ def mock_poll_query_status():
yield m
+@mock_aws
class TestAthenaSensor:
- def setup_method(self):
+ def setup_method(self, _):
self.default_op_kwargs = dict(
task_id="test_athena_sensor",
query_execution_id="abc",