def test_render_with_missing_profile(self): """ The field gets rendered without a data attribute. """ widget = RichTextWidget(field_settings='missing') expected = ('<div class="field-box">' '<textarea class="djrichtextfield" cols="40"' ' name="" rows="10">\r\n</textarea>' '</div>') self.assertHTMLEqual(expected, widget.render('', ''))
def test_render(self): """ Test that the rendered textarea is surrounded with a div and doesn't include any settings. """ widget = RichTextWidget() expected = ('<div class="field-box">' '<textarea class="djrichtextfield" cols="40"' ' name="" rows="10">\r\n</textarea>' '</div>') self.assertHTMLEqual(expected, widget.render('', ''))
def test_render_with_profile(self): """ The field includes the correct data attribute. """ widget = RichTextWidget(field_settings='simple') config = json.dumps(self.config['profiles']['simple']) expected = ('<div class="field-box">' '<textarea class="djrichtextfield" cols="40"' ' data-field-settings="{0}"' ' name="" rows="10">\r\n</textarea>' '</div>'.format(escape(config))) self.assertHTMLEqual(expected, widget.render('', ''))
def test_render_with_settings(self): """ The field includes the correct data attribute. """ settings = {'foo': False} widget = RichTextWidget(field_settings=settings) config = json.dumps(settings) expected = ('<div class="{0}">' '<textarea class="djrichtextfield" cols="40"' ' data-field-settings="{1}"' ' name="" rows="10">\r\n</textarea>' '</div>'.format(self.container_class, escape(config))) self.assertHTMLEqual(expected, widget.render('', ''))