Skip to content

Commit

Permalink
Standardize AWS Kinesis/Firehose naming (#20362)
Browse files Browse the repository at this point in the history
  • Loading branch information
ferruzzi authored Dec 17, 2021
1 parent 3d35408 commit f6a41a0
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 5 deletions.
19 changes: 18 additions & 1 deletion airflow/providers/amazon/aws/hooks/kinesis.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,13 @@
# under the License.

"""This module contains AWS Firehose hook"""
import warnings
from typing import Iterable

from airflow.providers.amazon.aws.hooks.base_aws import AwsBaseHook


class AwsFirehoseHook(AwsBaseHook):
class FirehoseHook(AwsBaseHook):
"""
Interact with AWS Kinesis Firehose.
Expand All @@ -46,3 +47,19 @@ def put_records(self, records: Iterable):
response = self.get_conn().put_record_batch(DeliveryStreamName=self.delivery_stream, Records=records)

return response


class AwsFirehoseHook(FirehoseHook):
"""
This hook is deprecated.
Please use :class:`airflow.providers.amazon.aws.hooks.kinesis.FirehoseHook`.
"""

def __init__(self, *args, **kwargs):
warnings.warn(
"This hook is deprecated. "
"Please use :class:`airflow.providers.amazon.aws.hooks.kinesis.FirehoseHook`.",
DeprecationWarning,
stacklevel=2,
)
super().__init__(*args, **kwargs)
8 changes: 4 additions & 4 deletions tests/providers/amazon/aws/hooks/test_kinesis.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
import boto3
import pytest

from airflow.providers.amazon.aws.hooks.kinesis import AwsFirehoseHook
from airflow.providers.amazon.aws.hooks.kinesis import FirehoseHook

try:
from moto import mock_firehose, mock_s3
Expand All @@ -30,10 +30,10 @@


@pytest.mark.skipif(mock_firehose is None, reason='moto package not present')
class TestAwsFirehoseHook:
class TestFirehoseHook:
@mock_firehose
def test_get_conn_returns_a_boto3_connection(self):
hook = AwsFirehoseHook(
hook = FirehoseHook(
aws_conn_id='aws_default', delivery_stream="test_airflow", region_name="us-east-1"
)
assert hook.get_conn() is not None
Expand All @@ -42,7 +42,7 @@ def test_get_conn_returns_a_boto3_connection(self):
@mock_s3
def test_insert_batch_records_kinesis_firehose(self):
boto3.client('s3').create_bucket(Bucket='kinesis-test')
hook = AwsFirehoseHook(
hook = FirehoseHook(
aws_conn_id='aws_default', delivery_stream="test_airflow", region_name="us-east-1"
)

Expand Down

0 comments on commit f6a41a0

Please sign in to comment.