Skip to content

Commit

Permalink
#973 Add an html validator
Browse files Browse the repository at this point in the history
  • Loading branch information
olegush committed Nov 30, 2019
1 parent c2f1959 commit 1f6b712
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 0 deletions.
2 changes: 2 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,5 @@ python-telegram-bot==11.1.0
sentry-sdk==0.7.2
https://github.com/selwin/django-user_agents/archive/master.zip
https://github.com/fidals/refarm-site/archive/0.7.2.zip
html5validate
html5lib
24 changes: 24 additions & 0 deletions shopelectro/tests/tests_html.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import os
import unittest

from django.test import TestCase, tag
from django.conf import settings
from django.template.loader import render_to_string

from html5validate import validate


@tag('fast')
class TemplateTests(TestCase):

@unittest.skip
def test_templates(self):
for dir, _, filenames in os.walk(settings.TEMPLATE_DIR):
for filename in filenames:
filepath = os.path.join(dir, filename)
filename, file_ext = os.path.splitext(filepath)
if file_ext == '.html':
validate(render_to_string(filepath))

def test_valid_example(self):
validate(render_to_string('/usr/app/src/templates/valid_example.html'))
12 changes: 12 additions & 0 deletions templates/valid_example.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>title</title>
<link rel="stylesheet" href="style.css">
<script src="script.js"></script>
</head>
<body>
<!-- page content -->
</body>
</html>

0 comments on commit 1f6b712

Please sign in to comment.