Exemplo n.º 1
0
    def test_multiple_messages(self):
        test_messages = [
            Message(constants.DEBUG, 'some debug message'),
            Message(constants.INFO, 'some info message')
        ]

        expected = {
            'messages': [{
                'text': 'some debug message',
                'tags': LEVEL_TAGS[constants.DEBUG]
            }, {
                'text': 'some info message',
                'tags': LEVEL_TAGS[constants.INFO]
            }]
        }
        self.assertEqual(messages(test_messages), expected)

        test_messages = [
            Message(constants.DEBUG, '[\'some debug message\']'),
            Message(constants.INFO, '[\'some info message\']')
        ]

        expected = {
            'messages': [{
                'text': 'some debug message',
                'tags': LEVEL_TAGS[constants.DEBUG]
            }, {
                'text': 'some info message',
                'tags': LEVEL_TAGS[constants.INFO]
            }]
        }

        self.assertEqual(messages(test_messages), expected)
Exemplo n.º 2
0
    def test_messages(self):

        for tag in self.tags:
            txt = 'some message with {}'.format(repr(tag))

            test_messages = [Message(tag, txt)]
            self.assertEqual(
                messages(test_messages),
                {'messages': [{'text': txt, 'tags': LEVEL_TAGS[tag]}]})  # clean one

            txt = '[\'some dirty message with {}\']'.format(repr(tag))
            txt_altered = txt.replace('[\'', '').replace('\']', '')
            test_messages = [Message(tag, txt)]
            self.assertEqual(
                messages(test_messages),
                {'messages': [{'text': txt_altered, 'tags': LEVEL_TAGS[tag]}]})  # dirty one
Exemplo n.º 3
0
    def test_multiple_messages(self):
        test_messages = [
            Message(constants.DEBUG, "some debug message"),
            Message(constants.INFO, "some info message")
        ]

        expected = {
            "messages": [
                {
                    "text": "some debug message",
                    "tags": LEVEL_TAGS[constants.DEBUG]
                },
                {
                    "text": "some info message",
                    "tags": LEVEL_TAGS[constants.INFO]
                },
            ]
        }
        self.assertEqual(messages(test_messages), expected)

        test_messages = [
            Message(constants.DEBUG, "['some debug message']"),
            Message(constants.INFO, "['some info message']"),
        ]

        expected = {
            "messages": [
                {
                    "text": "some debug message",
                    "tags": LEVEL_TAGS[constants.DEBUG]
                },
                {
                    "text": "some info message",
                    "tags": LEVEL_TAGS[constants.INFO]
                },
            ]
        }

        self.assertEqual(messages(test_messages), expected)
Exemplo n.º 4
0
    def test_messages(self):

        for tag in self.tags:
            txt = f"some message with {repr(tag)}"

            test_messages = [Message(tag, txt)]
            self.assertEqual(
                messages(test_messages),
                {"messages": [{
                    "text": txt,
                    "tags": LEVEL_TAGS[tag]
                }]})  # clean one

            txt = f"['some dirty message with {repr(tag)}']"
            txt_altered = txt.replace("['", "").replace("']", "")
            test_messages = [Message(tag, txt)]
            self.assertEqual(
                messages(test_messages),
                {"messages": [{
                    "text": txt_altered,
                    "tags": LEVEL_TAGS[tag]
                }]})  # dirty one
Exemplo n.º 5
0
    def test_messages(self):

        for tag in self.tags:
            txt = 'some message with {}'.format(repr(tag))

            test_messages = [Message(tag, txt)]
            self.assertEqual(
                messages(test_messages),
                {'messages': [{
                    'text': txt,
                    'tags': LEVEL_TAGS[tag]
                }]})  # clean one

            txt = '[\'some dirty message with {}\']'.format(repr(tag))
            txt_altered = txt.replace('[\'', '').replace('\']', '')
            test_messages = [Message(tag, txt)]
            self.assertEqual(
                messages(test_messages),
                {'messages': [{
                    'text': txt_altered,
                    'tags': LEVEL_TAGS[tag]
                }]})  # dirty one
Exemplo n.º 6
0
    def test_multiple_messages(self):
        test_messages = [
            Message(constants.DEBUG, 'some debug message'),
            Message(constants.INFO, 'some info message')
        ]

        expected = {'messages': [
            {'text': 'some debug message', 'tags': LEVEL_TAGS[constants.DEBUG]},
            {'text': 'some info message', 'tags': LEVEL_TAGS[constants.INFO]}
        ]}
        self.assertEqual(messages(test_messages), expected)

        test_messages = [
            Message(constants.DEBUG, '[\'some debug message\']'),
            Message(constants.INFO, '[\'some info message\']')
        ]

        expected = {'messages': [
            {'text': 'some debug message', 'tags': LEVEL_TAGS[constants.DEBUG]},
            {'text': 'some info message', 'tags': LEVEL_TAGS[constants.INFO]}
        ]}

        self.assertEqual(messages(test_messages), expected)
Exemplo n.º 7
0
 def test_no_messages(self):
     self.assertEqual(messages([]), {'messages': []})
Exemplo n.º 8
0
 def test_no_messages(self):
     self.assertEqual(messages([]), {"messages": []})