0
0
mirror of https://github.com/django/django.git synced 2024-12-01 15:42:04 +01:00
django/tests/messages_tests/tests.py
2022-02-07 20:37:05 +01:00

34 lines
1.1 KiB
Python

from unittest import mock
from django.contrib.messages import constants
from django.contrib.messages.storage import base
from django.contrib.messages.storage.base import Message
from django.test import SimpleTestCase, override_settings
class MessageTests(SimpleTestCase):
def test_eq(self):
msg_1 = Message(constants.INFO, "Test message 1")
msg_2 = Message(constants.INFO, "Test message 2")
msg_3 = Message(constants.WARNING, "Test message 1")
self.assertEqual(msg_1, msg_1)
self.assertEqual(msg_1, mock.ANY)
self.assertNotEqual(msg_1, msg_2)
self.assertNotEqual(msg_1, msg_3)
self.assertNotEqual(msg_2, msg_3)
class TestLevelTags(SimpleTestCase):
message_tags = {
constants.INFO: "info",
constants.DEBUG: "",
constants.WARNING: "",
constants.ERROR: "bad",
constants.SUCCESS: "",
12: "custom",
}
@override_settings(MESSAGE_TAGS=message_tags)
def test_override_settings_level_tags(self):
self.assertEqual(base.LEVEL_TAGS, self.message_tags)