From 585c71e72ad59fb533970fcce801a04b6c51f65f Mon Sep 17 00:00:00 2001 From: Mouse Reeve Date: Tue, 28 Sep 2021 10:21:12 -0700 Subject: [PATCH] Adds html linting to test --- Dockerfile | 2 +- bookwyrm/forms.py | 3 +-- bookwyrm/templates/layout.html | 4 ++-- bookwyrm/tests/views/test_edit_user.py | 7 ++++++- requirements.txt | 1 + 5 files changed, 11 insertions(+), 6 deletions(-) diff --git a/Dockerfile b/Dockerfile index 1892ae234..349dd82b1 100644 --- a/Dockerfile +++ b/Dockerfile @@ -8,4 +8,4 @@ WORKDIR /app COPY requirements.txt /app/ RUN pip install -r requirements.txt --no-cache-dir -RUN apt-get update && apt-get install -y gettext libgettextpo-dev && apt-get clean +RUN apt-get update && apt-get install -y gettext libgettextpo-dev tidy && apt-get clean diff --git a/bookwyrm/forms.py b/bookwyrm/forms.py index b9b93694c..9b410eaf6 100644 --- a/bookwyrm/forms.py +++ b/bookwyrm/forms.py @@ -29,8 +29,7 @@ class CustomForm(ModelForm): input_type = visible.field.widget.input_type if isinstance(visible.field.widget, Textarea): input_type = "textarea" - visible.field.widget.attrs["cols"] = None - visible.field.widget.attrs["rows"] = None + visible.field.widget.attrs["rows"] = 5 visible.field.widget.attrs["class"] = css_classes[input_type] diff --git a/bookwyrm/templates/layout.html b/bookwyrm/templates/layout.html index bf7a7f23e..ce3eee2ba 100644 --- a/bookwyrm/templates/layout.html +++ b/bookwyrm/templates/layout.html @@ -117,7 +117,7 @@ {% if perms.bookwyrm.create_invites or perms.moderate_user %} - + {% endif %} {% if perms.bookwyrm.create_invites and not site.allow_registration %}
  • @@ -133,7 +133,7 @@
  • {% endif %} - +
  • {% trans 'Log out' %} diff --git a/bookwyrm/tests/views/test_edit_user.py b/bookwyrm/tests/views/test_edit_user.py index 07e54e4e4..e465ba05f 100644 --- a/bookwyrm/tests/views/test_edit_user.py +++ b/bookwyrm/tests/views/test_edit_user.py @@ -3,6 +3,7 @@ import json import pathlib from unittest.mock import patch from PIL import Image +from tidylib import tidy_document from django.contrib.auth.models import AnonymousUser from django.contrib.sessions.middleware import SessionMiddleware @@ -59,7 +60,10 @@ class EditUserViews(TestCase): request.user = self.local_user result = view(request) self.assertIsInstance(result, TemplateResponse) - result.render() + html = result.render() + _, errors = tidy_document(html.content) + if errors: + raise Exception(errors) self.assertEqual(result.status_code, 200) def test_edit_user(self, _): @@ -93,6 +97,7 @@ class EditUserViews(TestCase): image_file = pathlib.Path(__file__).parent.joinpath( "../../static/images/no_cover.jpg" ) + # pylint: disable=consider-using-with form.data["avatar"] = SimpleUploadedFile( image_file, open(image_file, "rb").read(), content_type="image/jpeg" ) diff --git a/requirements.txt b/requirements.txt index f01f2bcbd..2d79a475b 100644 --- a/requirements.txt +++ b/requirements.txt @@ -26,3 +26,4 @@ pytest==6.1.2 pytest-cov==2.10.1 pytest-env==0.6.2 pytest-xdist==2.3.0 +pytidylib==0.3.2