def test_without_safe_extension_and_other(self): expected = markdown_filter(self.teststring, "nl2br") assert expected == ("<p>Test 123<br />\n" "<strong>Test</strong><br />\n" "<em>foo</em></p>") assert type(expected) is SafeText
def test_without_safe_extension(self): expected = markdown_filter(self.teststring) assert expected == ("<p>Test 123\n" "<strong>Test</strong>\n" "<em>foo</em></p>") assert type(expected) is SafeText
def test_valid_mailto_link(self): url = 'mailto://[email protected]' expected = '<p><a href="{0}">{0}</a></p>'.format(url) assert expected == markdown_filter(url)
def test_invalid_link(self): url = 'www.example.com' expected = '<p>{0}</p>'.format(url) assert expected == markdown_filter(url)
def test_file_render_success(self): expected = '<p><a href="{0}" title="" target="_self"></a></p>'.format( self.link.external_url) assert expected == markdown_filter('[link:{0}]'.format(self.link.pk))
def test_valid_http_link(self): url = 'https://www.youtube.com/watch?v=FTuFVwnrcts' expected = '<p><a href="{0}">{0}</a></p>'.format(url) assert expected == markdown_filter(url)
def test_link_not_found_debug(self, settings): settings.DEBUG = True with pytest.raises(AnyLink.DoesNotExist): markdown_filter('[link:999]')
def test_link_not_found_no_debug(self, settings): settings.DEBUG = False markdown_filter('[link:999]') == '<p></p>'
def test_image_render_success(self): expected = '<p><img src="{0}" alt="{1}" title="{2}"></p>'.format( self.image.url, self.image.default_alt_text, self.image.default_caption) assert expected == markdown_filter('[file:{0}]'.format(self.image.pk))
def test_invalid_tag(self): assert markdown_filter('foo [link:123 bar') == ('<p>foo [link:123 bar</p>')
def test_file_render_success(self): expected = '<p><a href="{0}">{0}</a></p>'.format(self.file.url) assert expected == markdown_filter('[file:{0}]'.format(self.file.pk))
def test_file_not_found_no_debug(self, settings): settings.DEBUG = False assert markdown_filter('foo [file:999] bar') == ('<p>foo bar</p>')
def test_file_not_found_debug(self, settings): settings.DEBUG = True with pytest.raises(File.DoesNotExist): markdown_filter('[file:999]')
def test_without_safe_extension(self): expected = markdown_filter(self.teststring) assert expected == ('<p>Test 123\n' '<strong>Test</strong>\n' '<em>foo</em></p>') assert type(expected) is SafeText
def test_without_safe_extension_and_other(self): expected = markdown_filter(self.teststring, 'nl2br') assert expected == ('<p>Test 123<br />\n' '<strong>Test</strong><br />\n' '<em>foo</em></p>') assert type(expected) is SafeText