def test_messages_service(self, skip=False): if not skip: self._init_memphis() service = IStatusMessage(self.request) self.assertTrue(IStatusMessage.providedBy(service)) self.assertEqual(service.messages(), ()) # add simple msg service.add('Test') msgs = service.messages() self.assertTrue(len(msgs) == 1) self.assertTrue(u'Test' in msgs[0]) # only one message service.add('Test') msgs = service.messages() self.assertTrue(len(msgs) == 1) # clear msgs = service.clear() self.assertTrue(len(msgs) == 1) self.assertTrue(u'Test' in msgs[0]) self.assertEqual(service.messages(), ()) self.assertEqual(service.clear(), ())
def test_messages_View(self): self._init_memphis() v = view.View(None, self.request) v.message('message') service = IStatusMessage(self.request) self.assertEqual( service.messages(), [u'<div class="alert-message info">\n <a class="close" href="#">\xd7</a>\n <p>message</p>\n</div>\n']) self.assertEqual( v.renderMessages(), u'<div class="alert-message info">\n <a class="close" href="#">\xd7</a>\n <p>message</p>\n</div>\n') self.assertEqual(service.messages(), ())