示例#1
0
    def test_publish_to_target_plain(self):
        hook = AwsSnsHook(aws_conn_id='aws_default')

        message = "Hello world"
        topic_name = "test-topic"
        target = hook.get_conn().create_topic(Name=topic_name).get('TopicArn')

        response = hook.publish_to_target(target, message)

        assert 'MessageId' in response
示例#2
0
    def test_publish_to_target_with_attributes(self):
        hook = AwsSnsHook(aws_conn_id='aws_default')

        message = "Hello world"
        topic_name = "test-topic"
        target = hook.get_conn().create_topic(Name=topic_name).get('TopicArn')

        response = hook.publish_to_target(target, message, message_attributes={
            'test-string': 'string-value',
            'test-number': 123456,
            'test-array': ['first', 'second', 'third'],
            'test-binary': b'binary-value',
        })

        assert 'MessageId' in response
示例#3
0
 def test_get_conn_returns_a_boto3_connection(self):
     hook = AwsSnsHook(aws_conn_id='aws_default')
     self.assertIsNotNone(hook.get_conn())