added tests for all formatters; stylecheck workflow now also checks in tests now

This commit is contained in:
truePhilipp committed 2024-05-06 22:26:45 +02:00
1 parent 2f3f45151d
commit c3f7fd88bb
18 files changed
+364 -14

No files matched your search

+11 -8
View File
@@ -4,17 +4,20 @@ from html_to_django.formatters import block_formatter
class BlockTests(TestCase):
def test_basic(self):
def test_basic(self) -> None:
soup = BeautifulSoup('<div dj-block="content"></div>', "html.parser")
block_formatter.format(soup)
self.assertEqual("{% block content %}{% endblock %}", str(soup))
def test_with_content(self):
expected_result = "{% block content %}{% endblock %}"
self.assertEqual(expected_result, str(soup))
def test_with_content(self) -> None:
soup = BeautifulSoup('<div dj-block="content">Test</div>', "html.parser")
block_formatter.format(soup)
self.assertEqual("{% block content %}Test{% endblock %}", str(soup))
def test_with_block_inside(self):
expected_result = "{% block content %}Test{% endblock %}"
self.assertEqual(expected_result, str(soup))
def test_with_block_inside(self) -> None:
soup = BeautifulSoup('<div dj-block="content"><div dj-block="inner">Test</div></div>', "html.parser")
block_formatter.format(soup)
self.assertEqual("{% block content %}{% block inner %}Test{% endblock %}{% endblock %}", str(soup))
expected_result = "{% block content %}{% block inner %}Test{% endblock %}{% endblock %}"
self.assertEqual(expected_result, str(soup))