Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Standardize Amazon SES naming #20367

Merged
merged 1 commit into from
Dec 18, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 17 additions & 1 deletion airflow/providers/amazon/aws/hooks/ses.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,14 @@
# specific language governing permissions and limitations
# under the License.
"""This module contains AWS SES Hook"""
import warnings
from typing import Any, Dict, Iterable, List, Optional, Union

from airflow.providers.amazon.aws.hooks.base_aws import AwsBaseHook
from airflow.utils.email import build_mime_message


class SESHook(AwsBaseHook):
class SesHook(AwsBaseHook):
"""
Interact with Amazon Simple Email Service.

Expand Down Expand Up @@ -95,3 +96,18 @@ def send_email(
return ses_client.send_raw_email(
Source=mail_from, Destinations=recipients, RawMessage={'Data': message.as_string()}
)


class SESHook(SesHook):
"""
This hook is deprecated.
Please use :class:`airflow.providers.amazon.aws.hooks.ses.SesHook`.
"""

def __init__(self, *args, **kwargs):
warnings.warn(
"This hook is deprecated. " "Please use :class:`airflow.providers.amazon.aws.hooks.ses.SesHook`.",
DeprecationWarning,
stacklevel=2,
)
super().__init__(*args, **kwargs)
4 changes: 2 additions & 2 deletions airflow/providers/amazon/aws/utils/emailer.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

from typing import List, Optional, Union

from airflow.providers.amazon.aws.hooks.ses import SESHook
from airflow.providers.amazon.aws.hooks.ses import SesHook


def send_email(
Expand All @@ -36,7 +36,7 @@ def send_email(
**kwargs,
) -> None:
"""Email backend for SES."""
hook = SESHook(aws_conn_id=conn_id)
hook = SesHook(aws_conn_id=conn_id)
hook.send_email(
mail_from=from_email,
to=to,
Expand Down
6 changes: 3 additions & 3 deletions tests/providers/amazon/aws/hooks/test_ses.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,14 @@
import pytest
from moto import mock_ses

from airflow.providers.amazon.aws.hooks.ses import SESHook
from airflow.providers.amazon.aws.hooks.ses import SesHook

boto3.setup_default_session()


@mock_ses
def test_get_conn():
hook = SESHook(aws_conn_id='aws_default')
hook = SesHook(aws_conn_id='aws_default')
assert hook.get_conn() is not None


Expand All @@ -42,7 +42,7 @@ def test_get_conn():
)
def test_send_email(to, cc, bcc):
# Given
hook = SESHook()
hook = SesHook()
ses_client = hook.get_conn()
mail_from = 'test_from@domain.com'

Expand Down
2 changes: 1 addition & 1 deletion tests/providers/amazon/aws/utils/test_emailer.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@


class TestSendEmailSes(TestCase):
@mock.patch("airflow.providers.amazon.aws.utils.emailer.SESHook")
@mock.patch("airflow.providers.amazon.aws.utils.emailer.SesHook")
def test_send_ses_email(self, mock_hook):
send_email(
from_email="From Test <from@test.com>",
Expand Down