Skip to content
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

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open

Conversation

olegush
Copy link
Collaborator

@olegush olegush commented Nov 30, 2019

Closes #973

@duker33 duker33 self-requested a review November 30, 2019 12:15
@duker33
Copy link
Contributor

duker33 commented Nov 30, 2019

@olegush , add plz "Closes #XXX" to the task body

@@ -0,0 +1,12 @@
<!DOCTYPE html>
Copy link
Contributor

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):
Copy link
Contributor

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

@olegush olegush closed this Dec 1, 2019
@olegush olegush reopened this Dec 1, 2019
@olegush olegush closed this Dec 1, 2019
@olegush olegush reopened this Dec 1, 2019
@olegush olegush closed this Dec 1, 2019
@olegush olegush reopened this Dec 1, 2019
Copy link
Contributor

@duker33 duker33 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just one fix

)
validate(render_to_string(filepath))

@unittest.expectedFailure
Copy link
Contributor

@duker33 duker33 Dec 1, 2019

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')
Copy link
Contributor

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):
Copy link
Contributor

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

Copy link
Collaborator Author

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?

Copy link
Contributor

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

@duker33
Copy link
Contributor

duker33 commented Dec 5, 2019

@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):
Copy link
Contributor

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],
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

11

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add an html validator to CI pipeline
2 participants