You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by GitBox <gi...@apache.org> on 2022/08/23 02:43:35 UTC

[GitHub] [airflow] uranusjr commented on a diff in pull request #25881: improve test coverage of SnsHook

uranusjr commented on code in PR #25881:
URL: https://github.com/apache/airflow/pull/25881#discussion_r952099310


##########
tests/providers/amazon/aws/hooks/test_sns.py:
##########
@@ -79,3 +79,26 @@ def test_publish_to_target_plain(self):
         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'>""",

Review Comment:
   ```suggestion
               "Values in MessageAttributes must be one of bytes, str, int, float, "
               "or iterable; got <class 'object'>",
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org