def test_widget_values(self): from plone.app.z3cform.widget import RichTextWidget from plone.app.textfield.value import RichTextValue widget = FieldWidget(self.field, RichTextWidget(self.request)) # set the context so we can get tinymce settings widget.context = self.portal widget.value = RichTextValue(u'Lorem ipsum \u2026') base_args = widget._base_args() self.assertEquals(base_args['value'], u'Lorem ipsum \u2026')
def test_dx_tinymcewidget_single_mimetype(self): """A RichTextWidget with only one available mimetype should render the pattern class directly on itself. """ if IMarkupSchema: # if not, don't run this test self._set_mimetypes(allowed=('text/html', )) from plone.app.z3cform.widget import RichTextWidget widget = FieldWidget(self.field, RichTextWidget(self.request)) # set the context so we can get tinymce settings widget.context = self.portal rendered = widget.render() self.assertTrue('<select' not in rendered) self.assertTrue('pat-tinymce' in rendered) self.assertTrue('data-pat-tinymce' in rendered)
def test_widget_params(self): from plone.app.z3cform.widget import RichTextWidget widget = FieldWidget(self.field, RichTextWidget(self.request)) # set the context so we can get tinymce settings widget.context = self.portal widget.update() base_args = widget._base_args() self.assertEqual(base_args['name'], 'text') self.assertEqual(base_args['value'], u'') self.assertEqual(base_args['pattern'], 'tinymce') self.assertEqual(base_args['pattern_options']['prependToUrl'], 'resolveuid/') self.assertEqual( base_args['pattern_options']['upload']['relativePath'], '@@fileUpload')
def test_dx_tinymcewidget_multiple_mimetypes_create(self): """A RichTextWidget with multiple available mimetypes should render a mimetype selection widget along with the textfield. When there is no field value, the default mimetype should be preselected. """ if IMarkupSchema: # if not, don't run this test self._set_mimetypes(allowed=('text/html', 'text/plain')) from plone.app.z3cform.widget import RichTextWidget widget = FieldWidget(self.field, RichTextWidget(self.request)) # set the context so we can get tinymce settings widget.context = self.portal rendered = widget.render() self.assertTrue('<select' in rendered) self.assertTrue('pat-textareamimetypeselector' in rendered) self.assertTrue('data-pat-textareamimetypeselector' in rendered) self.assertTrue( '<option value="text/html" selected="selected">' in rendered) self.assertTrue('pat-tinymce' not in rendered)