def test_pusher_bad_response(): """ Any exception from Pusher is ignored and logged to Sentry. Pusher is not critical enough to be worth causing an action to fail. """ get_pusher_location = "portfoliyo.pusher.events.get_pusher" logger_warning_location = "portfoliyo.pusher.events.logger.warning" with mock.patch(get_pusher_location) as mock_get_pusher: channel = mock_get_pusher.return_value["channel"] channel.trigger.side_effect = Exception("Unexpected return status 413") with mock.patch(logger_warning_location) as mock_logger_warning: events.trigger("channel", "event", {}) mock_logger_warning.assert_called_with( "Pusher exception: Unexpected return status 413", exc_info=True, extra={"stack": True} )
def test_pusher_bad_response(): """ Any exception from Pusher is ignored and logged to Sentry. Pusher is not critical enough to be worth causing an action to fail. """ get_pusher_location = 'portfoliyo.pusher.events.get_pusher' logger_warning_location = 'portfoliyo.pusher.events.logger.warning' with mock.patch(get_pusher_location) as mock_get_pusher: channel = mock_get_pusher.return_value['channel'] channel.trigger.side_effect = Exception('Unexpected return status 413') with mock.patch(logger_warning_location) as mock_logger_warning: events.trigger('channel', 'event', {}) mock_logger_warning.assert_called_with( "Pusher exception: Unexpected return status 413", exc_info=True, extra={'stack': True}, )
def test_pusher_socket_error(): """ A pusher socket error is logged to Sentry and then ignored. Pusher is not critical enough to be worth causing an action to fail. """ import socket get_pusher_location = "portfoliyo.pusher.events.get_pusher" logger_warning_location = "portfoliyo.pusher.events.logger.warning" with mock.patch(get_pusher_location) as mock_get_pusher: channel = mock_get_pusher.return_value["channel"] channel.trigger.side_effect = socket.error("connection timed out") with mock.patch(logger_warning_location) as mock_logger_warning: events.trigger("channel", "event", {}) mock_logger_warning.assert_called_with( "Pusher exception: connection timed out", exc_info=True, extra={"stack": True} )
def test_pusher_socket_error(): """ A pusher socket error is logged to Sentry and then ignored. Pusher is not critical enough to be worth causing an action to fail. """ import socket get_pusher_location = 'portfoliyo.pusher.events.get_pusher' logger_warning_location = 'portfoliyo.pusher.events.logger.warning' with mock.patch(get_pusher_location) as mock_get_pusher: channel = mock_get_pusher.return_value['channel'] channel.trigger.side_effect = socket.error('connection timed out') with mock.patch(logger_warning_location) as mock_logger_warning: events.trigger('channel', 'event', {}) mock_logger_warning.assert_called_with( "Pusher exception: connection timed out", exc_info=True, extra={'stack': True}, )