# -*- coding: utf-8 -*-

from mock import Mock
from unittest2 import TestCase
from raven.events import Message


class MessageTest(TestCase):

    def test_to_string(self):
        unformatted_message = 'My message from %s about %s'
        client = Mock()
        message = Message(client)
        message.logger = Mock()
        data = {
            'sentry.interfaces.Message': {
                'message': unformatted_message,
            }
        }

        self.assertEqual(message.to_string(data), unformatted_message)
        self.assertEqual(message.logger.warn.call_count, 1)

        args, kwargs = message.logger.warn.call_args
        self.assertEqual(args, ('Unable to find params for message',))
        self.assertEqual(kwargs,
                         {'extra': {'msg': {'message': unformatted_message}}})

        data['sentry.interfaces.Message']['params'] = (1, 2)
        self.assertEqual(message.to_string(data),
                         unformatted_message % (1, 2))

@@ -523,305 +523,8 @@
 age)
-%0A        self.assertEqual(message.logger.warn.call_count, 1)%0A%0A        args, kwargs = message.logger.warn.call_args%0A        self.assertEqual(args, ('Unable to find params for message',))%0A        self.assertEqual(kwargs,%0A                         %7B'extra': %7B'msg': %7B'message': unformatted_message%7D%7D%7D)
 %0A%0A  

Update test to match current behavior