-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
#973 Add an html validator #1020
base: master
Are you sure you want to change the base?
Conversation
@olegush , add plz "Closes #XXX" to the task body |
templates/valid_example.html
Outdated
@@ -0,0 +1,12 @@ | |||
<!DOCTYPE html> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- the file should live in
tests/assets/
valid_markup_example.html
would be more good name for the file
if file_ext == '.html': | ||
validate(render_to_string(filepath)) | ||
|
||
def test_valid_example(self): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you also should test not valid html
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just one fix
shopelectro/tests/tests_html.py
Outdated
) | ||
validate(render_to_string(filepath)) | ||
|
||
@unittest.expectedFailure |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use assertRaises instead of expectedFailure. The last one should be used only for tests that should be fixed in the future.
It should look like this:
with self.assertRaises(TypeError):
s.split(2)
@tag('fast') | ||
class TemplateTests(TestCase): | ||
|
||
@unittest.skip('should fix html templates') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
need PDD subtask there to fix every html file in templates
|
||
@unittest.skip('should fix html templates') | ||
def test_templates(self): | ||
for dir, _, filenames in os.walk(settings.TEMPLATE_DIR): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
settings.TEMPLATE_DIR
is redundant option, because we'll not redefine it for different envs and django extensions. You can move it to the module level const or just hardcode there.
We try to keep django settings files as small as possible to reduce problems with tuning prod/local envs
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
did you mean TEMPLATE_ASSETS_DIR?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@olegush , y, i meant it, sorry
@olegush , approved review, but two minor fixes is left. Implement them plz |
|
||
@unittest.skip('should fix html templates') | ||
def test_templates(self): | ||
for dir, _, filenames in os.walk(settings.TEMPLATE_DIR): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@olegush , y, i meant it, sorry
TEMPLATES = [ | ||
{ | ||
'BACKEND': 'django.template.backends.django.DjangoTemplates', | ||
'DIRS': [TEMPLATE_DIR], | ||
'DIRS': [TEMPLATE_DIR, TEMPLATE_ASSETS_DIR], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
11
Closes #973