Skip to content

Commit

Permalink
Standardize AWS Redshift naming (#20374)
Browse files Browse the repository at this point in the history
* Standardize AWS Redshift naming
  • Loading branch information
ferruzzi authored Jan 6, 2022
1 parent 64cba10 commit 88ea157
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 12 deletions.
6 changes: 4 additions & 2 deletions airflow/providers/amazon/aws/sensors/redshift.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,14 @@
# under the License.
import warnings

from airflow.providers.amazon.aws.sensors.redshift_cluster import AwsRedshiftClusterSensor
from airflow.providers.amazon.aws.sensors.redshift_cluster import RedshiftClusterSensor

AwsRedshiftClusterSensor = RedshiftClusterSensor

warnings.warn(
"This module is deprecated. Please use `airflow.providers.amazon.aws.sensors.redshift_cluster`.",
DeprecationWarning,
stacklevel=2,
)

__all__ = ["AwsRedshiftClusterSensor"]
__all__ = ["AwsRedshiftClusterSensor", "RedshiftClusterSensor"]
3 changes: 1 addition & 2 deletions airflow/providers/amazon/aws/sensors/redshift_cluster.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.

from typing import TYPE_CHECKING, Optional, Sequence

from airflow.providers.amazon.aws.hooks.redshift_cluster import RedshiftHook
Expand All @@ -24,7 +23,7 @@
from airflow.utils.context import Context


class AwsRedshiftClusterSensor(BaseSensorOperator):
class RedshiftClusterSensor(BaseSensorOperator):
"""
Waits for a Redshift cluster to reach a specific status.
Expand Down
5 changes: 5 additions & 0 deletions dev/provider_packages/prepare_provider_packages.py
Original file line number Diff line number Diff line change
Expand Up @@ -2187,6 +2187,11 @@ def summarise_total_vs_bad_and_warnings(total: int, bad: int, warns: List[warnin
'This module is deprecated. Please use `airflow.providers.amazon.aws.hooks.emr`.',
'This module is deprecated. Please use `airflow.providers.opsgenie.hooks.opsgenie`.',
'This module is deprecated. Please use `airflow.providers.opsgenie.operators.opsgenie`.',
'This module is deprecated. Please use `airflow.hooks.redshift_sql` '
'or `airflow.hooks.redshift_cluster` as appropriate.',
'This module is deprecated. Please use `airflow.providers.amazon.aws.operators.redshift_sql` or '
'`airflow.providers.amazon.aws.operators.redshift_cluster` as appropriate.',
'This module is deprecated. Please use `airflow.providers.amazon.aws.sensors.redshift_cluster`.',
}


Expand Down
4 changes: 4 additions & 0 deletions tests/deprecated_classes.py
Original file line number Diff line number Diff line change
Expand Up @@ -1784,6 +1784,10 @@
"airflow.providers.amazon.aws.sensors.s3.S3PrefixSensor",
"airflow.providers.amazon.aws.sensors.s3_prefix.S3PrefixSensor",
),
(
"airflow.providers.amazon.aws.sensors.redshift_cluster.RedshiftClusterSensor",
"airflow.providers.amazon.aws.sensors.redshift.RedshiftClusterSensor",
),
]

TRANSFERS = [
Expand Down
16 changes: 8 additions & 8 deletions tests/providers/amazon/aws/sensors/test_redshift_cluster.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,15 @@

import boto3

from airflow.providers.amazon.aws.sensors.redshift_cluster import AwsRedshiftClusterSensor
from airflow.providers.amazon.aws.sensors.redshift_cluster import RedshiftClusterSensor

try:
from moto import mock_redshift
except ImportError:
mock_redshift = None


class TestAwsRedshiftClusterSensor(unittest.TestCase):
class TestRedshiftClusterSensor(unittest.TestCase):
@staticmethod
def _create_cluster():
client = boto3.client('redshift', region_name='us-east-1')
Expand All @@ -44,21 +44,21 @@ def _create_cluster():
@mock_redshift
def test_poke(self):
self._create_cluster()
op = AwsRedshiftClusterSensor(
op = RedshiftClusterSensor(
task_id='test_cluster_sensor',
poke_interval=1,
timeout=5,
aws_conn_id='aws_default',
cluster_identifier='test_cluster',
target_status='available',
)
assert op.poke(None)
assert op.poke({})

@unittest.skipIf(mock_redshift is None, 'mock_redshift package not present')
@mock_redshift
def test_poke_false(self):
self._create_cluster()
op = AwsRedshiftClusterSensor(
op = RedshiftClusterSensor(
task_id='test_cluster_sensor',
poke_interval=1,
timeout=5,
Expand All @@ -67,13 +67,13 @@ def test_poke_false(self):
target_status='available',
)

assert not op.poke(None)
assert not op.poke({})

@unittest.skipIf(mock_redshift is None, 'mock_redshift package not present')
@mock_redshift
def test_poke_cluster_not_found(self):
self._create_cluster()
op = AwsRedshiftClusterSensor(
op = RedshiftClusterSensor(
task_id='test_cluster_sensor',
poke_interval=1,
timeout=5,
Expand All @@ -82,4 +82,4 @@ def test_poke_cluster_not_found(self):
target_status='cluster_not_found',
)

assert op.poke(None)
assert op.poke({})

0 comments on commit 88ea157

Please sign in to comment.