def test_messages_render(self): from ptah import view self.init_ptah() view.add_message(self.request, 'message') self.assertEqual( view.render_messages(self.request), text_('<div class="alert alert-info">\n <a class="close" data-dismiss="alert">×</a>\n message\n</div>\n','utf-8')) msg = view.render_messages(self.request) self.assertEqual(msg, '')
def test_messages_render(self): from ptah import view self.init_ptah() view.add_message(self.request, 'message') self.assertEqual( view.render_messages(self.request), text_('<div class="alert-message info">\n <a class="close" href="#">×</a>\n <p>message</p>\n</div>\n','utf-8')) #self.assertEqual(type(msg), unicode) msg = view.render_messages(self.request) self.assertEqual(msg, '')
def test_messages_render(self): self._init_ptah() view.add_message(self.request, 'message') msg = view.render_messages(self.request) self.assertEqual( '\n'.join(msg.split(os.linesep)), u'<div class="alert-message info">\n <a class="close" href="#">\xd7</a>\n <p>message</p>\n</div>\n') self.assertEqual(type(msg), unicode) msg = view.render_messages(self.request) self.assertEqual(msg, '')
def test_messages_error_msg(self): from ptah import view self.init_ptah() view.add_message(self.request, 'error', 'error') self.assertEqual( view.render_messages(self.request), text_('<div class="alert-message error">\n <a class="close" href="#">×</a>\n <p>error</p>\n</div>\n','utf-8')) view.add_message(self.request, ValueError('Error'), 'error') self.assertEqual( view.render_messages(self.request), text_('<div class="alert-message error">\n <a class="close" href="#">×</a>\n <p>ValueError: Error</p>\n</div>\n','utf-8'))
def test_messages_error_msg(self): from ptah import view self.init_ptah() view.add_message(self.request, 'error', 'error') self.assertEqual( view.render_messages(self.request), text_('<div class="alert alert-error">\n <a class="close" data-dismiss="alert">×</a>\n error\n</div>\n','utf-8')) view.add_message(self.request, ValueError('Error'), 'error') self.assertEqual( view.render_messages(self.request), text_('<div class="alert alert-error">\n <a class="close" data-dismiss="alert">×</a>\n ValueError: Error\n</div>\n','utf-8'))
def test_messages_render(self): from ptah import view self.init_ptah() view.add_message(self.request, 'message') self.assertEqual( view.render_messages(self.request), text_( '<div class="alert-message info">\n <a class="close" href="#">×</a>\n <p>message</p>\n</div>\n', 'utf-8')) #self.assertEqual(type(msg), unicode) msg = view.render_messages(self.request) self.assertEqual(msg, '')
def test_messages_unknown_type(self): from ptah import view self.init_ptah() view.add_message(self.request, 'message', 'unknown') self.assertEqual( view.render_messages(self.request), text_('message','utf-8'))
def test_messages_warning_msg(self): from ptah import view self.init_ptah() view.add_message(self.request, 'warning', 'warning') self.assertEqual( view.render_messages(self.request), text_('<div class="alert-message warning">\n <a class="close" href="#">×</a>\n <p>warning</p>\n</div>\n','utf-8'))
def test_messages_error_msg(self): from ptah import view self.init_ptah() view.add_message(self.request, 'error', 'error') self.assertEqual( view.render_messages(self.request), text_( '<div class="alert-message error">\n <a class="close" href="#">×</a>\n <p>error</p>\n</div>\n', 'utf-8')) view.add_message(self.request, ValueError('Error'), 'error') self.assertEqual( view.render_messages(self.request), text_( '<div class="alert-message error">\n <a class="close" href="#">×</a>\n <p>ValueError: Error</p>\n</div>\n', 'utf-8'))
def test_messages_warning_msg(self): from ptah import view self.init_ptah() view.add_message(self.request, 'warning', 'warning') self.assertEqual( view.render_messages(self.request), text_('<div class="alert alert-warning">\n <a class="close" data-dismiss="alert">×</a>\n warning\n</div>\n','utf-8'))
def test_messages_warning_msg(self): from ptah import view self.init_ptah() view.add_message(self.request, 'warning', 'warning') self.assertEqual( view.render_messages(self.request), text_( '<div class="alert-message warning">\n <a class="close" href="#">×</a>\n <p>warning</p>\n</div>\n', 'utf-8'))
def test_sharingform_search_error(self): from ptah.manage.apps import SharingForm app = self._make_app() form = SharingForm( app, DummyRequest(POST={'form.buttons.search': 'Search'})) form.csrf = False form.update() self.assertIn('Please specify search term', view.render_messages(form.request))
def test_sharingform_search_error(self): from ptah.manage.apps import SharingForm app = self._make_app() form = SharingForm(app, DummyRequest( POST={'form.buttons.search': 'Search'})) form.csrf = False form.update() self.assertIn('Please specify search term', view.render_messages(form.request))
def test_messages_custom_msg(self): from ptah import view @view.snippet('custom', view.Message) def customMessage(context, request): return '<div class="customMsg">{0}</div>'.format(context.message) self.init_ptah() view.add_message(self.request, 'message', 'custom') self.assertEqual(view.render_messages(self.request), '<div class="customMsg">message</div>')
def test_messages_addmessage(self): from ptah import view self.init_ptah() # add_message view.add_message(self.request, 'message') res = view.render_messages(self.request) self.assertEqual( res, text_('<div class="alert-message info">\n <a class="close" href="#">×</a>\n <p>message</p>\n</div>\n','utf-8'))
def test_messages_custom_msg(self): from ptah import view @view.snippet('custom', view.Message) def customMessage(context, request): return '<div class="customMsg">{0}</div>'.format(context.message) self.init_ptah() view.add_message(self.request, 'message', 'custom') self.assertEqual( view.render_messages(self.request), '<div class="customMsg">message</div>')
def test_messages_addmessage(self): from ptah import view self.init_ptah() # add_message view.add_message(self.request, 'message') res = view.render_messages(self.request) self.assertEqual( res, text_( '<div class="alert-message info">\n <a class="close" href="#">×</a>\n <p>message</p>\n</div>\n', 'utf-8'))