Skip to content

Commit

Permalink
improve test coverage of SnsHook (#25881)
Browse files Browse the repository at this point in the history
* improve test coverage of SnsHook
  • Loading branch information
eladkal committed Aug 23, 2022
1 parent 87c7867 commit 63d38b8
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions tests/providers/amazon/aws/hooks/test_sns.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'>",
str(ctx.exception),
)

0 comments on commit 63d38b8

Please sign in to comment.