Esempio n. 1
0
async def test_sns_handler_publisher_without_encoder(mock_boto_session_sns,
                                                     boto_client_sns):
    handler = SNSHandler('arn:aws:sns:whatever:topic-name')
    with mock_boto_session_sns as mock_sns:
        retval = await handler.publish('message', encoder=None)
        assert retval

        assert mock_sns.called
        assert boto_client_sns.publish.called
        assert boto_client_sns.publish.call_args == mock.call(
            TopicArn='arn:aws:sns:whatever:topic-name',
            MessageStructure='json',
            Message=json.dumps({'default': 'message'}))
Esempio n. 2
0
async def test_sns_handler_publisher_without_encoder(mock_boto_session_sns,
                                                     boto_client_sns):
    handler = SNSHandler("arn:aws:sns:whatever:topic-name")
    with mock_boto_session_sns as mock_sns:
        retval = await handler.publish("message", encoder=None)
        assert retval

        assert mock_sns.called
        assert boto_client_sns.publish.called
        assert boto_client_sns.publish.call_args == mock.call(
            TopicArn="arn:aws:sns:whatever:topic-name",
            MessageStructure="json",
            Message=json.dumps({"default": "message"}),
        )
Esempio n. 3
0
async def test_sns_handler_hadle():
    handler = SNSHandler('foobar')
    handler.publish = CoroutineMock()
    await handler.handle('message', 'metadata')
    assert handler.publish.called
    handler.publish.assert_called_once_with('message')
Esempio n. 4
0
async def test_sns_handler_publish_without_topic():
    handler = SNSHandler()
    with pytest.raises(ValueError):
        await handler.publish('wrong')
Esempio n. 5
0
async def test_sns_handler_hadle():
    handler = SNSHandler('foobar')
    handler.publish = CoroutineMock()
    await handler.handle('message', 'metadata')
    assert handler.publish.called
    assert handler.publish.called_once_with('message')
Esempio n. 6
0
async def test_sns_handler_hadle():
    handler = SNSHandler("foobar")
    handler.publish = AsyncMock()
    await handler.handle("message", "metadata")
    assert handler.publish.called
    handler.publish.assert_called_once_with("message")