def test_store(self):
     self.request._messages = default_storage(self.request)
     self.request._messages.level = DEBUG
     add_message(self.request, STORED_ERROR, "an SOS to the world ☢")
     add_message(self.request, DEBUG, "this won't be persisted ☢")
     self.assertEqual(len(get_messages(self.request)), 2)
     self.assertEqual(len(self.backend.archive_list(self.user)), 1)
 def test_store(self):
     self.request._messages = default_storage(self.request)
     self.request._messages.level = DEBUG
     add_message(self.request, STORED_ERROR, "an SOS to the world ☢")
     add_message(self.request, DEBUG, "this won't be persisted ☢")
     self.assertEqual(len(get_messages(self.request)), 2)
     self.assertEqual(len(self.backend.archive_list(self.user)), 1)
예제 #3
0
 def test_expire(self):
     self.request._messages = default_storage(self.request)
     add_message(self.request, STORED_ERROR, "an SOS to the world ☢")
     ma = MessageArchive.objects.all()[0]
     ma.message.date = now() - timedelta(days=365)
     ma.message.save()
     inbox = Inbox.objects.create(user=ma.user, message=ma.message)
     self.assertTrue(inbox.expired())
 def test_store(self):
     self.request._messages = default_storage(self.request)
     self.request._messages.level = DEBUG
     add_message(self.request, STORED_ERROR, "an SOS to the world ☢")
     add_message(self.request, DEBUG, "this won't be persisted ☢")
     storage = get_messages(self.request)
     self.assertEqual(len(storage), 2)
     self.assertEqual(MessageArchive.objects.filter(user=self.user).count(), 1)
 def test_store_anonymous(self):
     self.request.user = mock.MagicMock(wraps=self.user)
     self.request.user.is_anonymous.return_value = True
     self.request.user.is_authenticated.return_value = False
     self.request._messages = default_storage(self.request)
     add_message(self.request, STORED_ERROR, "an SOS to the world ☢")
     add_message(self.request, ERROR, "this error won't be persisted ☢")
     storage = get_messages(self.request)
     self.assertEqual(len(storage), 2)
 def test_store_anonymous(self):
     self.request.user = mock.MagicMock(wraps=self.user)
     self.request.user.is_anonymous.return_value = True
     self.request.user.is_authenticated.return_value = False
     self.request._messages = default_storage(self.request)
     add_message(self.request, STORED_ERROR, "an SOS to the world ☢")
     add_message(self.request, ERROR, "this error won't be persisted ☢")
     storage = get_messages(self.request)
     self.assertEqual(len(storage), 2)
예제 #7
0
def message_create_mixed(request):
    stored_messages.add_message(request, stored_messages.STORED_ERROR, "an error ☢")
    stored_messages.add_message(request, stored_messages.ERROR, "an error not persisted ☢")
    return HttpResponse()
예제 #8
0
def message_create(request):
    stored_messages.add_message(request, stored_messages.STORED_ERROR, "an error ☢")
    stored_messages.add_message(request, stored_messages.STORED_DEBUG, "a debug message ☢")
    return HttpResponse()
 def test_add_empty(self):
     self.request._messages = default_storage(self.request)
     add_message(self.request, DEBUG, '')
     self.assertEqual(len(get_messages(self.request)), 0)
 def test_add_empty(self):
     self.request._messages = default_storage(self.request)
     add_message(self.request, DEBUG, "")
     self.assertEqual(len(get_messages(self.request)), 0)
예제 #11
0
def message_create_mixed(request):
    stored_messages.add_message(request, stored_messages.STORED_ERROR,
                                "an error ☢")
    stored_messages.add_message(request, stored_messages.ERROR,
                                "an error not persisted ☢")
    return HttpResponse()
예제 #12
0
def message_create(request):
    stored_messages.add_message(request, stored_messages.STORED_ERROR,
                                "an error ☢")
    stored_messages.add_message(request, stored_messages.STORED_DEBUG,
                                "a debug message ☢")
    return HttpResponse()