def test_richtext_filters_unsafe_string(self): instance = models.UnsafeMenubutton.objects.create(entity='nobody') instance.save() pre_html = textwrap.dedent("""\ <div class='mezzanine-shortcodes' data-name='unsafe_menubutton' data-pk='{pk}' >""".format(pk=instance.pk)) with self.assertRaisesRegex(TypeError, 'safe string'): render.richtext_filters(pre_html)
def test_richtext_filters_error_dev(self): with self.assertRaisesRegex(self.model.DoesNotExist, 'does not exist'): render.richtext_filters(PRE_HTML.format(pk=100))
def test_richtext_filters_error_prod(self): with self.assertWarnsRegex(UserWarning, 'does not exist'): result = render.richtext_filters(PRE_HTML.format(pk=100)) expected_result = POST_HTML.format(content='') self.assertEqual(result, expected_result)
def test_richtext_filters(self): result = render.richtext_filters(PRE_HTML.format(pk=1)) expected_result = POST_HTML.format(content='<p>Hello Stanley!</p>') self.assertEqual(result, expected_result)