Merge branch 'unstable' into remove_azure

This commit is contained in:
Martin Whitehouse 2022-08-08 18:23:42 +02:00 committed by GitHub
commit b3051fb686
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 47 additions and 4 deletions

View File

@ -44,10 +44,9 @@ def format_time_spent(time_spent):
class EscapeHtml(Extension): class EscapeHtml(Extension):
def extendMarkdown(self, md, md_globals=None): def extendMarkdown(self, md):
# del md.preprocessors['html_block'] md.preprocessors.deregister('html_block')
# del md.inlinePatterns['html'] md.inlinePatterns.deregister('html')
pass
def get_markdown(text): def get_markdown(text):

View File

@ -0,0 +1,44 @@
from django.test import SimpleTestCase
from helpdesk.models import get_markdown
class MarkDown(SimpleTestCase):
"""Test work Markdown functional"""
def test_markdown_html_tab(self):
expected_value = "<p>&lt;div&gt;test&lt;div&gt;</p>"
input_value = "<div>test<div>"
output_value = get_markdown(input_value)
self.assertEqual(output_value, expected_value)
def test_markdown_nl2br(self):
""" warning, after Line 1 - two withespace, esle did't work"""
expected_value = "<p>Line 1<br />\n Line 2</p>"
input_value = """Line 1
Line 2"""
output_value = get_markdown(input_value)
self.assertEqual(output_value, expected_value)
def test_markdown_fenced_code(self):
expected_value = '<h1>Title</h1>\n<pre><code class="language-python"># import os\n</code></pre>'
input_value = """
# Title
```python
# import os
```
"""
output_value = get_markdown(input_value)
self.assertEqual(output_value, expected_value)
def test_markdown_link_correct_protokol(self):
expected_value = '<p><a href="http://www.yahoo.ru">www.google.com</a></p>'
input_value = "[www.google.com](http://www.yahoo.ru)"
output_value = get_markdown(input_value)
self.assertEqual(output_value, expected_value)
def test_markdown_link_not_correct_protokol(self):
expected_value = '<p><a href="//www.yahoo.ru">www.google.com</a></p>'
input_value = "[www.google.com](aaaa://www.yahoo.ru)"
output_value = get_markdown(input_value)
self.assertEqual(output_value, expected_value)