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 b8f2964d0fb Fix aws trigger tests, use get_async_conn for mock object
(#47515)
b8f2964d0fb is described below
commit b8f2964d0fb374549f60d5f3e4bcd7dad67b75ee
Author: GPK <[email protected]>
AuthorDate: Fri Mar 7 21:57:15 2025 +0000
Fix aws trigger tests, use get_async_conn for mock object (#47515)
---
.../amazon/tests/unit/amazon/aws/triggers/test_bedrock.py | 10 ++++------
.../amazon/tests/unit/amazon/aws/triggers/test_comprehend.py | 6 ++----
providers/amazon/tests/unit/amazon/aws/triggers/test_dms.py | 12 +++++-------
providers/amazon/tests/unit/amazon/aws/triggers/test_glue.py | 6 ++----
.../tests/unit/amazon/aws/triggers/test_glue_crawler.py | 4 +---
.../tests/unit/amazon/aws/triggers/test_kinesis_analytics.py | 6 ++----
.../unit/amazon/aws/triggers/test_opensearch_serverless.py | 4 +---
.../tests/unit/amazon/aws/triggers/test_serialization.py | 3 ---
8 files changed, 17 insertions(+), 34 deletions(-)
diff --git a/providers/amazon/tests/unit/amazon/aws/triggers/test_bedrock.py
b/providers/amazon/tests/unit/amazon/aws/triggers/test_bedrock.py
index 390ef64d728..457d7dc1d3d 100644
--- a/providers/amazon/tests/unit/amazon/aws/triggers/test_bedrock.py
+++ b/providers/amazon/tests/unit/amazon/aws/triggers/test_bedrock.py
@@ -33,8 +33,6 @@ from unit.amazon.aws.utils.test_waiter import
assert_expected_waiter_type
BASE_TRIGGER_CLASSPATH = "airflow.providers.amazon.aws.triggers.bedrock."
-pytest.importorskip("aiobotocore")
-
class TestBaseBedrockTrigger:
EXPECTED_WAITER_NAME: str | None = None
@@ -58,7 +56,7 @@ class
TestBedrockCustomizeModelCompletedTrigger(TestBaseBedrockTrigger):
@pytest.mark.asyncio
@mock.patch.object(BedrockHook, "get_waiter")
- @mock.patch.object(BedrockHook, "async_conn")
+ @mock.patch.object(BedrockHook, "get_async_conn")
async def test_run_success(self, mock_async_conn, mock_get_waiter):
mock_async_conn.__aenter__.return_value = mock.MagicMock()
mock_get_waiter().wait = AsyncMock()
@@ -87,7 +85,7 @@ class
TestBedrockProvisionModelThroughputCompletedTrigger(TestBaseBedrockTrigger
@pytest.mark.asyncio
@mock.patch.object(BedrockHook, "get_waiter")
- @mock.patch.object(BedrockHook, "async_conn")
+ @mock.patch.object(BedrockHook, "get_async_conn")
async def test_run_success(self, mock_async_conn, mock_get_waiter):
mock_async_conn.__aenter__.return_value = mock.MagicMock()
mock_get_waiter().wait = AsyncMock()
@@ -118,7 +116,7 @@ class
TestBedrockKnowledgeBaseActiveTrigger(TestBaseBedrockTrigger):
@pytest.mark.asyncio
@mock.patch.object(BedrockAgentHook, "get_waiter")
- @mock.patch.object(BedrockAgentHook, "async_conn")
+ @mock.patch.object(BedrockAgentHook, "get_async_conn")
async def test_run_success(self, mock_async_conn, mock_get_waiter):
mock_async_conn.__aenter__.return_value = mock.MagicMock()
mock_get_waiter().wait = AsyncMock()
@@ -154,7 +152,7 @@ class
TestBedrockIngestionJobTrigger(TestBaseBedrockTrigger):
@pytest.mark.asyncio
@mock.patch.object(BedrockAgentHook, "get_waiter")
- @mock.patch.object(BedrockAgentHook, "async_conn")
+ @mock.patch.object(BedrockAgentHook, "get_async_conn")
async def test_run_success(self, mock_async_conn, mock_get_waiter):
mock_async_conn.__aenter__.return_value = mock.MagicMock()
mock_get_waiter().wait = AsyncMock()
diff --git a/providers/amazon/tests/unit/amazon/aws/triggers/test_comprehend.py
b/providers/amazon/tests/unit/amazon/aws/triggers/test_comprehend.py
index cd98606697c..cf95594a9bc 100644
--- a/providers/amazon/tests/unit/amazon/aws/triggers/test_comprehend.py
+++ b/providers/amazon/tests/unit/amazon/aws/triggers/test_comprehend.py
@@ -31,8 +31,6 @@ from unit.amazon.aws.utils.test_waiter import
assert_expected_waiter_type
BASE_TRIGGER_CLASSPATH = "airflow.providers.amazon.aws.triggers.comprehend."
-pytest.importorskip("aiobotocore")
-
class TestBaseComprehendTrigger:
EXPECTED_WAITER_NAME: str | None = None
@@ -58,7 +56,7 @@ class
TestComprehendPiiEntitiesDetectionJobCompletedTrigger(TestBaseComprehendTr
@pytest.mark.asyncio
@mock.patch.object(ComprehendHook, "get_waiter")
- @mock.patch.object(ComprehendHook, "async_conn")
+ @mock.patch.object(ComprehendHook, "get_async_conn")
async def test_run_success(self, mock_async_conn, mock_get_waiter):
mock_async_conn.__aenter__.return_value = mock.MagicMock()
mock_get_waiter().wait = AsyncMock()
@@ -89,7 +87,7 @@ class TestComprehendCreateDocumentClassifierCompletedTrigger:
@pytest.mark.asyncio
@mock.patch.object(ComprehendHook, "get_waiter")
- @mock.patch.object(ComprehendHook, "async_conn")
+ @mock.patch.object(ComprehendHook, "get_async_conn")
async def test_run_success(self, mock_async_conn, mock_get_waiter):
mock_async_conn.__aenter__.return_value = mock.MagicMock()
mock_get_waiter().wait = AsyncMock()
diff --git a/providers/amazon/tests/unit/amazon/aws/triggers/test_dms.py
b/providers/amazon/tests/unit/amazon/aws/triggers/test_dms.py
index dc897136095..21764ebe886 100644
--- a/providers/amazon/tests/unit/amazon/aws/triggers/test_dms.py
+++ b/providers/amazon/tests/unit/amazon/aws/triggers/test_dms.py
@@ -34,8 +34,6 @@ from unit.amazon.aws.utils.test_waiter import
assert_expected_waiter_type
BASE_TRIGGER_CLASSPATH = "airflow.providers.amazon.aws.triggers.dms."
-pytest.importorskip("aiobotocore")
-
class TestBaseDmsTrigger:
EXPECTED_WAITER_NAME: str | None = None
@@ -59,7 +57,7 @@ class TestDmsReplicationCompleteTrigger(TestBaseDmsTrigger):
@pytest.mark.asyncio
@mock.patch.object(DmsHook, "get_waiter")
- @mock.patch.object(DmsHook, "get_conn")
+ @mock.patch.object(DmsHook, "get_async_conn")
async def test_complete(self, mock_async_conn, mock_get_waiter):
mock_async_conn.__aenter__.return_value = mock.MagicMock()
mock_get_waiter().wait = AsyncMock()
@@ -86,7 +84,7 @@ class
TestDmsReplicationTerminalStatusTrigger(TestBaseDmsTrigger):
@pytest.mark.asyncio
@mock.patch.object(DmsHook, "get_waiter")
- @mock.patch.object(DmsHook, "get_conn")
+ @mock.patch.object(DmsHook, "get_async_conn")
async def test_complete(self, mock_async_conn, mock_get_waiter):
mock_async_conn.__aenter__.return_value = mock.MagicMock()
mock_get_waiter().wait = AsyncMock()
@@ -115,7 +113,7 @@ class
TestDmsReplicationConfigDeletedTrigger(TestBaseDmsTrigger):
@pytest.mark.asyncio
@mock.patch.object(DmsHook, "get_waiter")
- @mock.patch.object(DmsHook, "get_conn")
+ @mock.patch.object(DmsHook, "get_async_conn")
async def test_complete(self, mock_async_conn, mock_get_waiter):
mock_async_conn.__aenter__.return_value = mock.MagicMock()
mock_get_waiter().wait = AsyncMock()
@@ -147,7 +145,7 @@ class TestDmsReplicationStoppedTrigger(TestBaseDmsTrigger):
@pytest.mark.asyncio
@mock.patch.object(DmsHook, "get_waiter")
- @mock.patch.object(DmsHook, "get_conn")
+ @mock.patch.object(DmsHook, "get_async_conn")
async def test_complete(self, mock_async_conn, mock_get_waiter):
mock_async_conn.__aenter__.return_value = mock.MagicMock()
mock_get_waiter().wait = AsyncMock()
@@ -175,7 +173,7 @@ class
TestDmsReplicationDeprovisionedTrigger(TestBaseDmsTrigger):
@pytest.mark.asyncio
@mock.patch.object(DmsHook, "get_waiter")
- @mock.patch.object(DmsHook, "get_conn")
+ @mock.patch.object(DmsHook, "get_async_conn")
async def test_complete(self, mock_async_conn, mock_get_waiter):
mock_async_conn.__aenter__.return_value = mock.MagicMock()
mock_get_waiter().wait = AsyncMock()
diff --git a/providers/amazon/tests/unit/amazon/aws/triggers/test_glue.py
b/providers/amazon/tests/unit/amazon/aws/triggers/test_glue.py
index 5bb3b44fe86..775deaf4538 100644
--- a/providers/amazon/tests/unit/amazon/aws/triggers/test_glue.py
+++ b/providers/amazon/tests/unit/amazon/aws/triggers/test_glue.py
@@ -36,8 +36,6 @@ from unit.amazon.aws.utils.test_waiter import
assert_expected_waiter_type
BASE_TRIGGER_CLASSPATH = "airflow.providers.amazon.aws.triggers.glue."
-pytest.importorskip("aiobotocore")
-
class TestGlueJobTrigger:
@pytest.mark.asyncio
@@ -155,7 +153,7 @@ class TestGlueDataQualityEvaluationRunCompletedTrigger:
@pytest.mark.asyncio
@mock.patch.object(GlueDataQualityHook, "get_waiter")
- @mock.patch.object(GlueDataQualityHook, "async_conn")
+ @mock.patch.object(GlueDataQualityHook, "get_async_conn")
async def test_run_success(self, mock_async_conn, mock_get_waiter):
mock_async_conn.__aenter__.return_value = mock.MagicMock()
mock_get_waiter().wait = AsyncMock()
@@ -182,7 +180,7 @@ class
TestGlueDataQualityRuleRecommendationRunCompleteTrigger:
@pytest.mark.asyncio
@mock.patch.object(GlueDataQualityHook, "get_waiter")
- @mock.patch.object(GlueDataQualityHook, "async_conn")
+ @mock.patch.object(GlueDataQualityHook, "get_async_conn")
async def test_run_success(self, mock_async_conn, mock_get_waiter):
mock_async_conn.__aenter__.return_value = mock.MagicMock()
mock_get_waiter().wait = AsyncMock()
diff --git
a/providers/amazon/tests/unit/amazon/aws/triggers/test_glue_crawler.py
b/providers/amazon/tests/unit/amazon/aws/triggers/test_glue_crawler.py
index c21e982bf8f..1fc951d8316 100644
--- a/providers/amazon/tests/unit/amazon/aws/triggers/test_glue_crawler.py
+++ b/providers/amazon/tests/unit/amazon/aws/triggers/test_glue_crawler.py
@@ -26,8 +26,6 @@ from airflow.providers.amazon.aws.triggers.glue_crawler
import GlueCrawlerComple
from airflow.triggers.base import TriggerEvent
from unit.amazon.aws.utils.test_waiter import assert_expected_waiter_type
-pytest.importorskip("aiobotocore")
-
class TestGlueCrawlerCompleteTrigger:
def test_serialization(self):
@@ -52,7 +50,7 @@ class TestGlueCrawlerCompleteTrigger:
@pytest.mark.asyncio
@mock.patch.object(GlueCrawlerHook, "get_waiter")
- @mock.patch.object(GlueCrawlerHook, "async_conn")
+ @mock.patch.object(GlueCrawlerHook, "get_async_conn")
async def test_run_success(self, mock_async_conn, mock_get_waiter):
mock_async_conn.__aenter__.return_value = mock.MagicMock()
mock_get_waiter().wait = AsyncMock()
diff --git
a/providers/amazon/tests/unit/amazon/aws/triggers/test_kinesis_analytics.py
b/providers/amazon/tests/unit/amazon/aws/triggers/test_kinesis_analytics.py
index 494f287783e..93629197a81 100644
--- a/providers/amazon/tests/unit/amazon/aws/triggers/test_kinesis_analytics.py
+++ b/providers/amazon/tests/unit/amazon/aws/triggers/test_kinesis_analytics.py
@@ -30,8 +30,6 @@ from unit.amazon.aws.utils.test_waiter import
assert_expected_waiter_type
BASE_TRIGGER_CLASSPATH =
"airflow.providers.amazon.aws.triggers.kinesis_analytics."
-pytest.importorskip("aiobotocore")
-
class TestKinesisAnalyticsV2ApplicationOperationCompleteTrigger:
APPLICATION_NAME = "demo"
@@ -47,7 +45,7 @@ class
TestKinesisAnalyticsV2ApplicationOperationCompleteTrigger:
@pytest.mark.asyncio
@mock.patch.object(KinesisAnalyticsV2Hook, "get_waiter")
- @mock.patch.object(KinesisAnalyticsV2Hook, "async_conn")
+ @mock.patch.object(KinesisAnalyticsV2Hook, "get_async_conn")
async def test_run_success_with_application_start_complete_waiter(self,
mock_async_conn, mock_get_waiter):
mock_async_conn.__aenter__.return_value = mock.MagicMock()
mock_get_waiter().wait = AsyncMock()
@@ -64,7 +62,7 @@ class
TestKinesisAnalyticsV2ApplicationOperationCompleteTrigger:
@pytest.mark.asyncio
@mock.patch.object(KinesisAnalyticsV2Hook, "get_waiter")
- @mock.patch.object(KinesisAnalyticsV2Hook, "async_conn")
+ @mock.patch.object(KinesisAnalyticsV2Hook, "get_async_conn")
async def test_run_success_with_application_stop_complete_waiter(self,
mock_async_conn, mock_get_waiter):
mock_async_conn.__aenter__.return_value = mock.MagicMock()
mock_get_waiter().wait = AsyncMock()
diff --git
a/providers/amazon/tests/unit/amazon/aws/triggers/test_opensearch_serverless.py
b/providers/amazon/tests/unit/amazon/aws/triggers/test_opensearch_serverless.py
index d4707f89a53..1ad6a478e3a 100644
---
a/providers/amazon/tests/unit/amazon/aws/triggers/test_opensearch_serverless.py
+++
b/providers/amazon/tests/unit/amazon/aws/triggers/test_opensearch_serverless.py
@@ -31,8 +31,6 @@ from unit.amazon.aws.triggers.test_base import
TestAwsBaseWaiterTrigger
BASE_TRIGGER_CLASSPATH =
"airflow.providers.amazon.aws.triggers.opensearch_serverless."
-pytest.importorskip("aiobotocore")
-
class TestBaseBedrockTrigger(TestAwsBaseWaiterTrigger):
EXPECTED_WAITER_NAME: str | None = None
@@ -77,7 +75,7 @@ class TestOpenSearchServerlessCollectionActiveTrigger:
@pytest.mark.asyncio
@mock.patch.object(OpenSearchServerlessHook, "get_waiter")
- @mock.patch.object(OpenSearchServerlessHook, "async_conn")
+ @mock.patch.object(OpenSearchServerlessHook, "get_async_conn")
async def test_run_success(self, mock_async_conn, mock_get_waiter):
mock_async_conn.__aenter__.return_value = mock.MagicMock()
mock_get_waiter().wait = AsyncMock()
diff --git
a/providers/amazon/tests/unit/amazon/aws/triggers/test_serialization.py
b/providers/amazon/tests/unit/amazon/aws/triggers/test_serialization.py
index d5b6a0a74b4..446a799c482 100644
--- a/providers/amazon/tests/unit/amazon/aws/triggers/test_serialization.py
+++ b/providers/amazon/tests/unit/amazon/aws/triggers/test_serialization.py
@@ -108,9 +108,6 @@ AWS_CONN_ID = "aws_batch_job_conn"
AWS_REGION = "us-east-2"
-pytest.importorskip("aiobotocore")
-
-
def gen_test_name(trigger):
"""Gives to tests the name of the class being tested."""
return trigger.__class__.__name__