This is an automated email from the ASF dual-hosted git repository.
eladkal 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 63d38b82a9 improve test coverage of SnsHook (#25881)
63d38b82a9 is described below
commit 63d38b82a93595021dfdb438eadb6e8ef2ded7af
Author: eladkal <[email protected]>
AuthorDate: Tue Aug 23 11:26:40 2022 +0300
improve test coverage of SnsHook (#25881)
* improve test coverage of SnsHook
---
tests/providers/amazon/aws/hooks/test_sns.py | 23 +++++++++++++++++++++++
1 file changed, 23 insertions(+)
diff --git a/tests/providers/amazon/aws/hooks/test_sns.py
b/tests/providers/amazon/aws/hooks/test_sns.py
index b3fa768f3b..ba42ba9209 100644
--- a/tests/providers/amazon/aws/hooks/test_sns.py
+++ b/tests/providers/amazon/aws/hooks/test_sns.py
@@ -79,3 +79,26 @@ class TestSnsHook(unittest.TestCase):
response = hook.publish_to_target(target, message)
assert 'MessageId' in response
+
+ @mock_sns
+ def test_publish_to_target_error(self):
+ hook = SnsHook(aws_conn_id='aws_default')
+
+ message = "Hello world"
+ topic_name = "test-topic"
+ target = hook.get_conn().create_topic(Name=topic_name).get('TopicArn')
+
+ with self.assertRaises(TypeError) as ctx:
+ hook.publish_to_target(
+ target,
+ message,
+ message_attributes={
+ 'test-non-iterable': object(),
+ },
+ )
+
+ self.assertEqual(
+ "Values in MessageAttributes must be one of bytes, str, int,
float, "
+ "or iterable; got <class 'object'>",
+ str(ctx.exception),
+ )