forked from mirrors/bookwyrm
Helper function for html validation
This commit is contained in:
parent
9c78a9d95c
commit
bdb1d1998a
17 changed files with 76 additions and 338 deletions
20
bookwyrm/tests/validate_html.py
Normal file
20
bookwyrm/tests/validate_html.py
Normal file
|
@ -0,0 +1,20 @@
|
||||||
|
""" html validation on rendered templates """
|
||||||
|
from tidylib import tidy_document
|
||||||
|
|
||||||
|
def validate_html(html):
|
||||||
|
""" run tidy on html """
|
||||||
|
_, errors = tidy_document(
|
||||||
|
html.content,
|
||||||
|
options={
|
||||||
|
"drop-empty-elements": False,
|
||||||
|
"warn-proprietary-attributes": False,
|
||||||
|
},
|
||||||
|
)
|
||||||
|
# idk how else to filter out these unescape amp errs
|
||||||
|
errors = "\n".join(
|
||||||
|
e
|
||||||
|
for e in errors.split("\n")
|
||||||
|
if "&book" not in e and "id and name attribute" not in e
|
||||||
|
)
|
||||||
|
if errors:
|
||||||
|
raise Exception(errors)
|
|
@ -1,12 +1,11 @@
|
||||||
""" test for app action functionality """
|
""" test for app action functionality """
|
||||||
from unittest.mock import patch
|
from unittest.mock import patch
|
||||||
from tidylib import tidy_document
|
|
||||||
from django.template.response import TemplateResponse
|
from django.template.response import TemplateResponse
|
||||||
from django.test import TestCase
|
from django.test import TestCase
|
||||||
from django.test.client import RequestFactory
|
from django.test.client import RequestFactory
|
||||||
|
|
||||||
from bookwyrm import models, views
|
from bookwyrm import models, views
|
||||||
|
from bookwyrm.tests.validate_html import validate_html
|
||||||
|
|
||||||
class DashboardViews(TestCase):
|
class DashboardViews(TestCase):
|
||||||
"""every response to a get request, html or json"""
|
"""every response to a get request, html or json"""
|
||||||
|
@ -35,8 +34,5 @@ class DashboardViews(TestCase):
|
||||||
request.user.is_superuser = True
|
request.user.is_superuser = True
|
||||||
result = view(request)
|
result = view(request)
|
||||||
self.assertIsInstance(result, TemplateResponse)
|
self.assertIsInstance(result, TemplateResponse)
|
||||||
html = result.render()
|
validate_html(result.render())
|
||||||
_, errors = tidy_document(html.content)
|
|
||||||
if errors:
|
|
||||||
raise Exception(errors)
|
|
||||||
self.assertEqual(result.status_code, 200)
|
self.assertEqual(result.status_code, 200)
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
""" test for app action functionality """
|
""" test for app action functionality """
|
||||||
from unittest.mock import patch
|
from unittest.mock import patch
|
||||||
from tidylib import tidy_document
|
|
||||||
|
|
||||||
from django.template.response import TemplateResponse
|
from django.template.response import TemplateResponse
|
||||||
from django.test import TestCase
|
from django.test import TestCase
|
||||||
from django.test.client import RequestFactory
|
from django.test.client import RequestFactory
|
||||||
|
|
||||||
from bookwyrm import models, views
|
from bookwyrm import models, views
|
||||||
|
from bookwyrm.tests.validate_html import validate_html
|
||||||
|
|
||||||
|
|
||||||
class EmailBlocklistViews(TestCase):
|
class EmailBlocklistViews(TestCase):
|
||||||
|
@ -38,10 +38,7 @@ class EmailBlocklistViews(TestCase):
|
||||||
result = view(request)
|
result = view(request)
|
||||||
|
|
||||||
self.assertIsInstance(result, TemplateResponse)
|
self.assertIsInstance(result, TemplateResponse)
|
||||||
html = result.render()
|
validate_html(result.render())
|
||||||
_, errors = tidy_document(html.content, options={"drop-empty-elements": False})
|
|
||||||
if errors:
|
|
||||||
raise Exception(errors)
|
|
||||||
self.assertEqual(result.status_code, 200)
|
self.assertEqual(result.status_code, 200)
|
||||||
|
|
||||||
def test_blocklist_page_post(self):
|
def test_blocklist_page_post(self):
|
||||||
|
@ -54,10 +51,7 @@ class EmailBlocklistViews(TestCase):
|
||||||
result = view(request)
|
result = view(request)
|
||||||
|
|
||||||
self.assertIsInstance(result, TemplateResponse)
|
self.assertIsInstance(result, TemplateResponse)
|
||||||
html = result.render()
|
validate_html(result.render())
|
||||||
_, errors = tidy_document(html.content, options={"drop-empty-elements": False})
|
|
||||||
if errors:
|
|
||||||
raise Exception(errors)
|
|
||||||
self.assertEqual(result.status_code, 200)
|
self.assertEqual(result.status_code, 200)
|
||||||
|
|
||||||
self.assertTrue(
|
self.assertTrue(
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
""" test for app action functionality """
|
""" test for app action functionality """
|
||||||
import json
|
import json
|
||||||
from unittest.mock import patch
|
from unittest.mock import patch
|
||||||
from tidylib import tidy_document
|
|
||||||
|
|
||||||
from django.core.files.uploadedfile import SimpleUploadedFile
|
from django.core.files.uploadedfile import SimpleUploadedFile
|
||||||
from django.template.response import TemplateResponse
|
from django.template.response import TemplateResponse
|
||||||
|
@ -9,6 +8,7 @@ from django.test import TestCase
|
||||||
from django.test.client import RequestFactory
|
from django.test.client import RequestFactory
|
||||||
|
|
||||||
from bookwyrm import forms, models, views
|
from bookwyrm import forms, models, views
|
||||||
|
from bookwyrm.tests.validate_html import validate_html
|
||||||
|
|
||||||
|
|
||||||
class FederationViews(TestCase):
|
class FederationViews(TestCase):
|
||||||
|
@ -48,16 +48,7 @@ class FederationViews(TestCase):
|
||||||
request.user.is_superuser = True
|
request.user.is_superuser = True
|
||||||
result = view(request)
|
result = view(request)
|
||||||
self.assertIsInstance(result, TemplateResponse)
|
self.assertIsInstance(result, TemplateResponse)
|
||||||
html = result.render()
|
validate_html(result.render())
|
||||||
_, errors = tidy_document(
|
|
||||||
html.content,
|
|
||||||
options={
|
|
||||||
"drop-empty-elements": False,
|
|
||||||
"warn-proprietary-attributes": False,
|
|
||||||
},
|
|
||||||
)
|
|
||||||
if errors:
|
|
||||||
raise Exception(errors)
|
|
||||||
self.assertEqual(result.status_code, 200)
|
self.assertEqual(result.status_code, 200)
|
||||||
|
|
||||||
def test_instance_page(self):
|
def test_instance_page(self):
|
||||||
|
@ -70,10 +61,7 @@ class FederationViews(TestCase):
|
||||||
|
|
||||||
result = view(request, server.id)
|
result = view(request, server.id)
|
||||||
self.assertIsInstance(result, TemplateResponse)
|
self.assertIsInstance(result, TemplateResponse)
|
||||||
html = result.render()
|
validate_html(result.render())
|
||||||
_, errors = tidy_document(html.content, options={"drop-empty-elements": False})
|
|
||||||
if errors:
|
|
||||||
raise Exception(errors)
|
|
||||||
self.assertEqual(result.status_code, 200)
|
self.assertEqual(result.status_code, 200)
|
||||||
|
|
||||||
def test_server_page_block(self):
|
def test_server_page_block(self):
|
||||||
|
@ -162,10 +150,7 @@ class FederationViews(TestCase):
|
||||||
|
|
||||||
result = view(request)
|
result = view(request)
|
||||||
self.assertIsInstance(result, TemplateResponse)
|
self.assertIsInstance(result, TemplateResponse)
|
||||||
html = result.render()
|
validate_html(result.render())
|
||||||
_, errors = tidy_document(html.content)
|
|
||||||
if errors:
|
|
||||||
raise Exception(errors)
|
|
||||||
self.assertEqual(result.status_code, 200)
|
self.assertEqual(result.status_code, 200)
|
||||||
|
|
||||||
def test_add_view_post_create(self):
|
def test_add_view_post_create(self):
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
""" test for app action functionality """
|
""" test for app action functionality """
|
||||||
from unittest.mock import patch
|
from unittest.mock import patch
|
||||||
from tidylib import tidy_document
|
|
||||||
from django.template.response import TemplateResponse
|
from django.template.response import TemplateResponse
|
||||||
from django.test import TestCase
|
from django.test import TestCase
|
||||||
from django.test.client import RequestFactory
|
from django.test.client import RequestFactory
|
||||||
|
|
||||||
from bookwyrm import models, views
|
from bookwyrm import models, views
|
||||||
|
from bookwyrm.tests.validate_html import validate_html
|
||||||
|
|
||||||
|
|
||||||
class IPBlocklistViews(TestCase):
|
class IPBlocklistViews(TestCase):
|
||||||
|
@ -37,8 +37,5 @@ class IPBlocklistViews(TestCase):
|
||||||
result = view(request)
|
result = view(request)
|
||||||
|
|
||||||
self.assertIsInstance(result, TemplateResponse)
|
self.assertIsInstance(result, TemplateResponse)
|
||||||
html = result.render()
|
validate_html(result.render())
|
||||||
_, errors = tidy_document(html.content, options={"drop-empty-elements": False})
|
|
||||||
if errors:
|
|
||||||
raise Exception(errors)
|
|
||||||
self.assertEqual(result.status_code, 200)
|
self.assertEqual(result.status_code, 200)
|
||||||
|
|
|
@ -1,13 +1,13 @@
|
||||||
""" test for app action functionality """
|
""" test for app action functionality """
|
||||||
import json
|
import json
|
||||||
from unittest.mock import patch
|
from unittest.mock import patch
|
||||||
from tidylib import tidy_document
|
|
||||||
|
|
||||||
from django.template.response import TemplateResponse
|
from django.template.response import TemplateResponse
|
||||||
from django.test import TestCase
|
from django.test import TestCase
|
||||||
from django.test.client import RequestFactory
|
from django.test.client import RequestFactory
|
||||||
|
|
||||||
from bookwyrm import forms, models, views
|
from bookwyrm import forms, models, views
|
||||||
|
from bookwyrm.tests.validate_html import validate_html
|
||||||
|
|
||||||
|
|
||||||
class ReportViews(TestCase):
|
class ReportViews(TestCase):
|
||||||
|
@ -44,16 +44,7 @@ class ReportViews(TestCase):
|
||||||
|
|
||||||
result = view(request)
|
result = view(request)
|
||||||
self.assertIsInstance(result, TemplateResponse)
|
self.assertIsInstance(result, TemplateResponse)
|
||||||
html = result.render()
|
validate_html(result.render())
|
||||||
_, errors = tidy_document(
|
|
||||||
html.content,
|
|
||||||
options={
|
|
||||||
"drop-empty-elements": False,
|
|
||||||
"warn-proprietary-attributes": False,
|
|
||||||
},
|
|
||||||
)
|
|
||||||
if errors:
|
|
||||||
raise Exception(errors)
|
|
||||||
self.assertEqual(result.status_code, 200)
|
self.assertEqual(result.status_code, 200)
|
||||||
|
|
||||||
def test_reports_page_with_data(self):
|
def test_reports_page_with_data(self):
|
||||||
|
@ -66,16 +57,7 @@ class ReportViews(TestCase):
|
||||||
|
|
||||||
result = view(request)
|
result = view(request)
|
||||||
self.assertIsInstance(result, TemplateResponse)
|
self.assertIsInstance(result, TemplateResponse)
|
||||||
html = result.render()
|
validate_html(result.render())
|
||||||
_, errors = tidy_document(
|
|
||||||
html.content,
|
|
||||||
options={
|
|
||||||
"drop-empty-elements": False,
|
|
||||||
"warn-proprietary-attributes": False,
|
|
||||||
},
|
|
||||||
)
|
|
||||||
if errors:
|
|
||||||
raise Exception(errors)
|
|
||||||
self.assertEqual(result.status_code, 200)
|
self.assertEqual(result.status_code, 200)
|
||||||
|
|
||||||
def test_report_page(self):
|
def test_report_page(self):
|
||||||
|
@ -89,10 +71,7 @@ class ReportViews(TestCase):
|
||||||
result = view(request, report.id)
|
result = view(request, report.id)
|
||||||
|
|
||||||
self.assertIsInstance(result, TemplateResponse)
|
self.assertIsInstance(result, TemplateResponse)
|
||||||
html = result.render()
|
validate_html(result.render())
|
||||||
_, errors = tidy_document(html.content, options={"drop-empty-elements": False})
|
|
||||||
if errors:
|
|
||||||
raise Exception(errors)
|
|
||||||
self.assertEqual(result.status_code, 200)
|
self.assertEqual(result.status_code, 200)
|
||||||
|
|
||||||
def test_report_comment(self):
|
def test_report_comment(self):
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
""" test for app action functionality """
|
""" test for app action functionality """
|
||||||
from unittest.mock import patch
|
from unittest.mock import patch
|
||||||
from tidylib import tidy_document
|
|
||||||
|
|
||||||
from django.contrib.auth.models import Group
|
from django.contrib.auth.models import Group
|
||||||
from django.template.response import TemplateResponse
|
from django.template.response import TemplateResponse
|
||||||
|
@ -8,6 +7,7 @@ from django.test import TestCase
|
||||||
from django.test.client import RequestFactory
|
from django.test.client import RequestFactory
|
||||||
|
|
||||||
from bookwyrm import models, views
|
from bookwyrm import models, views
|
||||||
|
from bookwyrm.tests.validate_html import validate_html
|
||||||
|
|
||||||
|
|
||||||
class UserAdminViews(TestCase):
|
class UserAdminViews(TestCase):
|
||||||
|
@ -36,10 +36,7 @@ class UserAdminViews(TestCase):
|
||||||
request.user.is_superuser = True
|
request.user.is_superuser = True
|
||||||
result = view(request)
|
result = view(request)
|
||||||
self.assertIsInstance(result, TemplateResponse)
|
self.assertIsInstance(result, TemplateResponse)
|
||||||
html = result.render()
|
validate_html(result.render())
|
||||||
_, errors = tidy_document(html.content, options={"drop-empty-elements": False})
|
|
||||||
if errors:
|
|
||||||
raise Exception(errors)
|
|
||||||
self.assertEqual(result.status_code, 200)
|
self.assertEqual(result.status_code, 200)
|
||||||
|
|
||||||
def test_user_admin_page(self):
|
def test_user_admin_page(self):
|
||||||
|
@ -52,10 +49,7 @@ class UserAdminViews(TestCase):
|
||||||
result = view(request, self.local_user.id)
|
result = view(request, self.local_user.id)
|
||||||
|
|
||||||
self.assertIsInstance(result, TemplateResponse)
|
self.assertIsInstance(result, TemplateResponse)
|
||||||
html = result.render()
|
validate_html(result.render())
|
||||||
_, errors = tidy_document(html.content, options={"drop-empty-elements": False})
|
|
||||||
if errors:
|
|
||||||
raise Exception(errors)
|
|
||||||
self.assertEqual(result.status_code, 200)
|
self.assertEqual(result.status_code, 200)
|
||||||
|
|
||||||
@patch("bookwyrm.suggested_users.rerank_suggestions_task.delay")
|
@patch("bookwyrm.suggested_users.rerank_suggestions_task.delay")
|
||||||
|
@ -77,10 +71,7 @@ class UserAdminViews(TestCase):
|
||||||
result = view(request, self.local_user.id)
|
result = view(request, self.local_user.id)
|
||||||
|
|
||||||
self.assertIsInstance(result, TemplateResponse)
|
self.assertIsInstance(result, TemplateResponse)
|
||||||
html = result.render()
|
validate_html(result.render())
|
||||||
_, errors = tidy_document(html.content, options={"drop-empty-elements": False})
|
|
||||||
if errors:
|
|
||||||
raise Exception(errors)
|
|
||||||
|
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
list(self.local_user.groups.values_list("name", flat=True)), ["editor"]
|
list(self.local_user.groups.values_list("name", flat=True)), ["editor"]
|
||||||
|
|
|
@ -2,7 +2,6 @@
|
||||||
from io import BytesIO
|
from io import BytesIO
|
||||||
import pathlib
|
import pathlib
|
||||||
from unittest.mock import patch
|
from unittest.mock import patch
|
||||||
from tidylib import tidy_document
|
|
||||||
|
|
||||||
from PIL import Image
|
from PIL import Image
|
||||||
import responses
|
import responses
|
||||||
|
@ -18,6 +17,7 @@ from django.utils import timezone
|
||||||
|
|
||||||
from bookwyrm import forms, models, views
|
from bookwyrm import forms, models, views
|
||||||
from bookwyrm.activitypub import ActivitypubResponse
|
from bookwyrm.activitypub import ActivitypubResponse
|
||||||
|
from bookwyrm.tests.validate_html import validate_html
|
||||||
|
|
||||||
|
|
||||||
class BookViews(TestCase):
|
class BookViews(TestCase):
|
||||||
|
@ -68,22 +68,8 @@ class BookViews(TestCase):
|
||||||
is_api.return_value = False
|
is_api.return_value = False
|
||||||
result = view(request, self.book.id)
|
result = view(request, self.book.id)
|
||||||
self.assertIsInstance(result, TemplateResponse)
|
self.assertIsInstance(result, TemplateResponse)
|
||||||
html = result.render()
|
validate_html(result.render())
|
||||||
_, errors = tidy_document(
|
|
||||||
html.content,
|
|
||||||
options={
|
|
||||||
"drop-empty-elements": False,
|
|
||||||
"warn-proprietary-attributes": False,
|
|
||||||
},
|
|
||||||
)
|
|
||||||
# idk how else to filter out these unescape amp errs
|
|
||||||
errors = "\n".join(
|
|
||||||
e
|
|
||||||
for e in errors.split("\n")
|
|
||||||
if "&book" not in e and "id and name attribute" not in e
|
|
||||||
)
|
|
||||||
if errors:
|
|
||||||
raise Exception(errors)
|
|
||||||
self.assertEqual(result.status_code, 200)
|
self.assertEqual(result.status_code, 200)
|
||||||
|
|
||||||
with patch("bookwyrm.views.books.books.is_api_request") as is_api:
|
with patch("bookwyrm.views.books.books.is_api_request") as is_api:
|
||||||
|
@ -123,21 +109,8 @@ class BookViews(TestCase):
|
||||||
is_api.return_value = False
|
is_api.return_value = False
|
||||||
result = view(request, self.book.id, user_statuses="review")
|
result = view(request, self.book.id, user_statuses="review")
|
||||||
self.assertIsInstance(result, TemplateResponse)
|
self.assertIsInstance(result, TemplateResponse)
|
||||||
html = result.render()
|
validate_html(result.render())
|
||||||
_, errors = tidy_document(
|
|
||||||
html.content,
|
|
||||||
options={
|
|
||||||
"drop-empty-elements": False,
|
|
||||||
"warn-proprietary-attributes": False,
|
|
||||||
},
|
|
||||||
)
|
|
||||||
errors = "\n".join(
|
|
||||||
e
|
|
||||||
for e in errors.split("\n")
|
|
||||||
if "&book" not in e and "id and name attribute" not in e
|
|
||||||
)
|
|
||||||
if errors:
|
|
||||||
raise Exception(errors)
|
|
||||||
self.assertEqual(result.status_code, 200)
|
self.assertEqual(result.status_code, 200)
|
||||||
self.assertEqual(result.context_data["statuses"].object_list[0], review)
|
self.assertEqual(result.context_data["statuses"].object_list[0], review)
|
||||||
|
|
||||||
|
@ -145,21 +118,7 @@ class BookViews(TestCase):
|
||||||
is_api.return_value = False
|
is_api.return_value = False
|
||||||
result = view(request, self.book.id, user_statuses="comment")
|
result = view(request, self.book.id, user_statuses="comment")
|
||||||
self.assertIsInstance(result, TemplateResponse)
|
self.assertIsInstance(result, TemplateResponse)
|
||||||
html = result.render()
|
validate_html(result.render())
|
||||||
_, errors = tidy_document(
|
|
||||||
html.content,
|
|
||||||
options={
|
|
||||||
"drop-empty-elements": False,
|
|
||||||
"warn-proprietary-attributes": False,
|
|
||||||
},
|
|
||||||
)
|
|
||||||
errors = "\n".join(
|
|
||||||
e
|
|
||||||
for e in errors.split("\n")
|
|
||||||
if "&book" not in e and "id and name attribute" not in e
|
|
||||||
)
|
|
||||||
if errors:
|
|
||||||
raise Exception(errors)
|
|
||||||
self.assertEqual(result.status_code, 200)
|
self.assertEqual(result.status_code, 200)
|
||||||
self.assertEqual(result.context_data["statuses"].object_list[0], comment)
|
self.assertEqual(result.context_data["statuses"].object_list[0], comment)
|
||||||
|
|
||||||
|
@ -167,21 +126,7 @@ class BookViews(TestCase):
|
||||||
is_api.return_value = False
|
is_api.return_value = False
|
||||||
result = view(request, self.book.id, user_statuses="quotation")
|
result = view(request, self.book.id, user_statuses="quotation")
|
||||||
self.assertIsInstance(result, TemplateResponse)
|
self.assertIsInstance(result, TemplateResponse)
|
||||||
html = result.render()
|
validate_html(result.render())
|
||||||
_, errors = tidy_document(
|
|
||||||
html.content,
|
|
||||||
options={
|
|
||||||
"drop-empty-elements": False,
|
|
||||||
"warn-proprietary-attributes": False,
|
|
||||||
},
|
|
||||||
)
|
|
||||||
errors = "\n".join(
|
|
||||||
e
|
|
||||||
for e in errors.split("\n")
|
|
||||||
if "&book" not in e and "id and name attribute" not in e
|
|
||||||
)
|
|
||||||
if errors:
|
|
||||||
raise Exception(errors)
|
|
||||||
self.assertEqual(result.status_code, 200)
|
self.assertEqual(result.status_code, 200)
|
||||||
self.assertEqual(result.context_data["statuses"].object_list[0], quote)
|
self.assertEqual(result.context_data["statuses"].object_list[0], quote)
|
||||||
|
|
||||||
|
@ -203,21 +148,7 @@ class BookViews(TestCase):
|
||||||
with patch("bookwyrm.views.books.books.is_api_request") as is_api:
|
with patch("bookwyrm.views.books.books.is_api_request") as is_api:
|
||||||
is_api.return_value = False
|
is_api.return_value = False
|
||||||
result = view(request, self.work.id)
|
result = view(request, self.work.id)
|
||||||
html = result.render()
|
validate_html(result.render())
|
||||||
_, errors = tidy_document(
|
|
||||||
html.content,
|
|
||||||
options={
|
|
||||||
"drop-empty-elements": False,
|
|
||||||
"warn-proprietary-attributes": False,
|
|
||||||
},
|
|
||||||
)
|
|
||||||
errors = "\n".join(
|
|
||||||
e
|
|
||||||
for e in errors.split("\n")
|
|
||||||
if "&book" not in e and "id and name attribute" not in e
|
|
||||||
)
|
|
||||||
if errors:
|
|
||||||
raise Exception(errors)
|
|
||||||
self.assertEqual(result.status_code, 200)
|
self.assertEqual(result.status_code, 200)
|
||||||
self.assertEqual(result.context_data["book"], self.book)
|
self.assertEqual(result.context_data["book"], self.book)
|
||||||
|
|
||||||
|
@ -229,21 +160,7 @@ class BookViews(TestCase):
|
||||||
request.user.is_superuser = True
|
request.user.is_superuser = True
|
||||||
result = view(request, self.book.id)
|
result = view(request, self.book.id)
|
||||||
self.assertIsInstance(result, TemplateResponse)
|
self.assertIsInstance(result, TemplateResponse)
|
||||||
html = result.render()
|
validate_html(result.render())
|
||||||
_, errors = tidy_document(
|
|
||||||
html.content,
|
|
||||||
options={
|
|
||||||
"drop-empty-elements": False,
|
|
||||||
"warn-proprietary-attributes": False,
|
|
||||||
},
|
|
||||||
)
|
|
||||||
errors = "\n".join(
|
|
||||||
e
|
|
||||||
for e in errors.split("\n")
|
|
||||||
if "&book" not in e and "id and name attribute" not in e
|
|
||||||
)
|
|
||||||
if errors:
|
|
||||||
raise Exception(errors)
|
|
||||||
self.assertEqual(result.status_code, 200)
|
self.assertEqual(result.status_code, 200)
|
||||||
|
|
||||||
def test_edit_book(self):
|
def test_edit_book(self):
|
||||||
|
@ -274,16 +191,7 @@ class BookViews(TestCase):
|
||||||
request.user = self.local_user
|
request.user = self.local_user
|
||||||
|
|
||||||
result = view(request, self.book.id)
|
result = view(request, self.book.id)
|
||||||
html = result.render()
|
validate_html(result.render())
|
||||||
_, errors = tidy_document(
|
|
||||||
html.content,
|
|
||||||
options={
|
|
||||||
"drop-empty-elements": False,
|
|
||||||
"warn-proprietary-attributes": False,
|
|
||||||
},
|
|
||||||
)
|
|
||||||
if errors:
|
|
||||||
raise Exception(errors)
|
|
||||||
|
|
||||||
# the changes haven't been saved yet
|
# the changes haven't been saved yet
|
||||||
self.book.refresh_from_db()
|
self.book.refresh_from_db()
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
""" test for app action functionality """
|
""" test for app action functionality """
|
||||||
from unittest.mock import patch
|
from unittest.mock import patch
|
||||||
from tidylib import tidy_document
|
|
||||||
|
|
||||||
from django.template.response import TemplateResponse
|
from django.template.response import TemplateResponse
|
||||||
from django.test import TestCase
|
from django.test import TestCase
|
||||||
|
@ -8,6 +7,7 @@ from django.test.client import RequestFactory
|
||||||
|
|
||||||
from bookwyrm import models, views
|
from bookwyrm import models, views
|
||||||
from bookwyrm.activitypub import ActivitypubResponse
|
from bookwyrm.activitypub import ActivitypubResponse
|
||||||
|
from bookwyrm.tests.validate_html import validate_html
|
||||||
|
|
||||||
|
|
||||||
class BookViews(TestCase):
|
class BookViews(TestCase):
|
||||||
|
@ -45,16 +45,7 @@ class BookViews(TestCase):
|
||||||
is_api.return_value = False
|
is_api.return_value = False
|
||||||
result = view(request, self.work.id)
|
result = view(request, self.work.id)
|
||||||
self.assertIsInstance(result, TemplateResponse)
|
self.assertIsInstance(result, TemplateResponse)
|
||||||
html = result.render()
|
validate_html(result.render())
|
||||||
_, errors = tidy_document(
|
|
||||||
html.content,
|
|
||||||
options={
|
|
||||||
"drop-empty-elements": False,
|
|
||||||
"warn-proprietary-attributes": False,
|
|
||||||
},
|
|
||||||
)
|
|
||||||
if errors:
|
|
||||||
raise Exception(errors)
|
|
||||||
self.assertEqual(result.status_code, 200)
|
self.assertEqual(result.status_code, 200)
|
||||||
self.assertTrue("paperback" in result.context_data["formats"])
|
self.assertTrue("paperback" in result.context_data["formats"])
|
||||||
|
|
||||||
|
@ -71,16 +62,7 @@ class BookViews(TestCase):
|
||||||
is_api.return_value = False
|
is_api.return_value = False
|
||||||
result = view(request, self.work.id)
|
result = view(request, self.work.id)
|
||||||
self.assertIsInstance(result, TemplateResponse)
|
self.assertIsInstance(result, TemplateResponse)
|
||||||
html = result.render()
|
validate_html(result.render())
|
||||||
_, errors = tidy_document(
|
|
||||||
html.content,
|
|
||||||
options={
|
|
||||||
"drop-empty-elements": False,
|
|
||||||
"warn-proprietary-attributes": False,
|
|
||||||
},
|
|
||||||
)
|
|
||||||
if errors:
|
|
||||||
raise Exception(errors)
|
|
||||||
self.assertEqual(result.status_code, 200)
|
self.assertEqual(result.status_code, 200)
|
||||||
self.assertEqual(len(result.context_data["editions"].object_list), 2)
|
self.assertEqual(len(result.context_data["editions"].object_list), 2)
|
||||||
self.assertEqual(len(result.context_data["formats"]), 2)
|
self.assertEqual(len(result.context_data["formats"]), 2)
|
||||||
|
@ -91,16 +73,7 @@ class BookViews(TestCase):
|
||||||
with patch("bookwyrm.views.editions.is_api_request") as is_api:
|
with patch("bookwyrm.views.editions.is_api_request") as is_api:
|
||||||
is_api.return_value = False
|
is_api.return_value = False
|
||||||
result = view(request, self.work.id)
|
result = view(request, self.work.id)
|
||||||
html = result.render()
|
validate_html(result.render())
|
||||||
_, errors = tidy_document(
|
|
||||||
html.content,
|
|
||||||
options={
|
|
||||||
"drop-empty-elements": False,
|
|
||||||
"warn-proprietary-attributes": False,
|
|
||||||
},
|
|
||||||
)
|
|
||||||
if errors:
|
|
||||||
raise Exception(errors)
|
|
||||||
self.assertEqual(result.status_code, 200)
|
self.assertEqual(result.status_code, 200)
|
||||||
self.assertEqual(len(result.context_data["editions"].object_list), 1)
|
self.assertEqual(len(result.context_data["editions"].object_list), 1)
|
||||||
|
|
||||||
|
@ -108,16 +81,7 @@ class BookViews(TestCase):
|
||||||
with patch("bookwyrm.views.editions.is_api_request") as is_api:
|
with patch("bookwyrm.views.editions.is_api_request") as is_api:
|
||||||
is_api.return_value = False
|
is_api.return_value = False
|
||||||
result = view(request, self.work.id)
|
result = view(request, self.work.id)
|
||||||
html = result.render()
|
validate_html(result.render())
|
||||||
_, errors = tidy_document(
|
|
||||||
html.content,
|
|
||||||
options={
|
|
||||||
"drop-empty-elements": False,
|
|
||||||
"warn-proprietary-attributes": False,
|
|
||||||
},
|
|
||||||
)
|
|
||||||
if errors:
|
|
||||||
raise Exception(errors)
|
|
||||||
self.assertEqual(result.status_code, 200)
|
self.assertEqual(result.status_code, 200)
|
||||||
self.assertEqual(len(result.context_data["editions"].object_list), 1)
|
self.assertEqual(len(result.context_data["editions"].object_list), 1)
|
||||||
|
|
||||||
|
@ -125,16 +89,7 @@ class BookViews(TestCase):
|
||||||
with patch("bookwyrm.views.editions.is_api_request") as is_api:
|
with patch("bookwyrm.views.editions.is_api_request") as is_api:
|
||||||
is_api.return_value = False
|
is_api.return_value = False
|
||||||
result = view(request, self.work.id)
|
result = view(request, self.work.id)
|
||||||
html = result.render()
|
validate_html(result.render())
|
||||||
_, errors = tidy_document(
|
|
||||||
html.content,
|
|
||||||
options={
|
|
||||||
"drop-empty-elements": False,
|
|
||||||
"warn-proprietary-attributes": False,
|
|
||||||
},
|
|
||||||
)
|
|
||||||
if errors:
|
|
||||||
raise Exception(errors)
|
|
||||||
self.assertEqual(result.status_code, 200)
|
self.assertEqual(result.status_code, 200)
|
||||||
self.assertEqual(len(result.context_data["editions"].object_list), 1)
|
self.assertEqual(len(result.context_data["editions"].object_list), 1)
|
||||||
|
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
""" test for app action functionality """
|
""" test for app action functionality """
|
||||||
from unittest.mock import patch
|
from unittest.mock import patch
|
||||||
from tidylib import tidy_document
|
|
||||||
|
|
||||||
from django.template.response import TemplateResponse
|
from django.template.response import TemplateResponse
|
||||||
from django.test import TestCase
|
from django.test import TestCase
|
||||||
from django.test.client import RequestFactory
|
from django.test.client import RequestFactory
|
||||||
|
|
||||||
from bookwyrm import models, views
|
from bookwyrm import models, views
|
||||||
|
from bookwyrm.tests.validate_html import validate_html
|
||||||
|
|
||||||
|
|
||||||
@patch("bookwyrm.models.activitypub_mixin.broadcast_task.delay")
|
@patch("bookwyrm.models.activitypub_mixin.broadcast_task.delay")
|
||||||
|
@ -46,10 +46,7 @@ class BlockViews(TestCase):
|
||||||
request.user = self.local_user
|
request.user = self.local_user
|
||||||
result = view(request)
|
result = view(request)
|
||||||
self.assertIsInstance(result, TemplateResponse)
|
self.assertIsInstance(result, TemplateResponse)
|
||||||
html = result.render()
|
validate_html(result.render())
|
||||||
_, errors = tidy_document(html.content)
|
|
||||||
if errors:
|
|
||||||
raise Exception(errors)
|
|
||||||
self.assertEqual(result.status_code, 200)
|
self.assertEqual(result.status_code, 200)
|
||||||
|
|
||||||
def test_block_post(self, _):
|
def test_block_post(self, _):
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
""" test for app action functionality """
|
""" test for app action functionality """
|
||||||
from unittest.mock import patch
|
from unittest.mock import patch
|
||||||
from tidylib import tidy_document
|
|
||||||
|
|
||||||
from django.template.response import TemplateResponse
|
from django.template.response import TemplateResponse
|
||||||
from django.test import TestCase
|
from django.test import TestCase
|
||||||
from django.test.client import RequestFactory
|
from django.test.client import RequestFactory
|
||||||
|
|
||||||
from bookwyrm import models, views
|
from bookwyrm import models, views
|
||||||
|
from bookwyrm.tests.validate_html import validate_html
|
||||||
|
|
||||||
|
|
||||||
class ChangePasswordViews(TestCase):
|
class ChangePasswordViews(TestCase):
|
||||||
|
@ -35,10 +35,7 @@ class ChangePasswordViews(TestCase):
|
||||||
|
|
||||||
result = view(request)
|
result = view(request)
|
||||||
self.assertIsInstance(result, TemplateResponse)
|
self.assertIsInstance(result, TemplateResponse)
|
||||||
html = result.render()
|
validate_html(result.render())
|
||||||
_, errors = tidy_document(html.content)
|
|
||||||
if errors:
|
|
||||||
raise Exception(errors)
|
|
||||||
self.assertEqual(result.status_code, 200)
|
self.assertEqual(result.status_code, 200)
|
||||||
|
|
||||||
def test_password_change(self):
|
def test_password_change(self):
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
""" test for app action functionality """
|
""" test for app action functionality """
|
||||||
import json
|
import json
|
||||||
from unittest.mock import patch
|
from unittest.mock import patch
|
||||||
from tidylib import tidy_document
|
|
||||||
|
|
||||||
from django.contrib.sessions.middleware import SessionMiddleware
|
from django.contrib.sessions.middleware import SessionMiddleware
|
||||||
from django.template.response import TemplateResponse
|
from django.template.response import TemplateResponse
|
||||||
|
@ -9,6 +8,7 @@ from django.test import TestCase
|
||||||
from django.test.client import RequestFactory
|
from django.test.client import RequestFactory
|
||||||
|
|
||||||
from bookwyrm import forms, models, views
|
from bookwyrm import forms, models, views
|
||||||
|
from bookwyrm.tests.validate_html import validate_html
|
||||||
|
|
||||||
|
|
||||||
@patch("bookwyrm.suggested_users.remove_user_task.delay")
|
@patch("bookwyrm.suggested_users.remove_user_task.delay")
|
||||||
|
@ -53,10 +53,7 @@ class DeleteUserViews(TestCase):
|
||||||
request.user = self.local_user
|
request.user = self.local_user
|
||||||
result = view(request)
|
result = view(request)
|
||||||
self.assertIsInstance(result, TemplateResponse)
|
self.assertIsInstance(result, TemplateResponse)
|
||||||
html = result.render()
|
validate_html(result.render())
|
||||||
_, errors = tidy_document(html.content)
|
|
||||||
if errors:
|
|
||||||
raise Exception(errors)
|
|
||||||
self.assertEqual(result.status_code, 200)
|
self.assertEqual(result.status_code, 200)
|
||||||
|
|
||||||
@patch("bookwyrm.suggested_users.rerank_suggestions_task")
|
@patch("bookwyrm.suggested_users.rerank_suggestions_task")
|
||||||
|
|
|
@ -2,7 +2,6 @@
|
||||||
import pathlib
|
import pathlib
|
||||||
from unittest.mock import patch
|
from unittest.mock import patch
|
||||||
from PIL import Image
|
from PIL import Image
|
||||||
from tidylib import tidy_document
|
|
||||||
|
|
||||||
from django.contrib.auth.models import AnonymousUser
|
from django.contrib.auth.models import AnonymousUser
|
||||||
from django.core.files.base import ContentFile
|
from django.core.files.base import ContentFile
|
||||||
|
@ -12,6 +11,7 @@ from django.test import TestCase
|
||||||
from django.test.client import RequestFactory
|
from django.test.client import RequestFactory
|
||||||
|
|
||||||
from bookwyrm import forms, models, views
|
from bookwyrm import forms, models, views
|
||||||
|
from bookwyrm.tests.validate_html import validate_html
|
||||||
|
|
||||||
|
|
||||||
@patch("bookwyrm.suggested_users.remove_user_task.delay")
|
@patch("bookwyrm.suggested_users.remove_user_task.delay")
|
||||||
|
@ -58,10 +58,7 @@ class EditUserViews(TestCase):
|
||||||
request.user = self.local_user
|
request.user = self.local_user
|
||||||
result = view(request)
|
result = view(request)
|
||||||
self.assertIsInstance(result, TemplateResponse)
|
self.assertIsInstance(result, TemplateResponse)
|
||||||
html = result.render()
|
validate_html(result.render())
|
||||||
_, errors = tidy_document(html.content)
|
|
||||||
if errors:
|
|
||||||
raise Exception(errors)
|
|
||||||
self.assertEqual(result.status_code, 200)
|
self.assertEqual(result.status_code, 200)
|
||||||
|
|
||||||
def test_edit_user(self, _):
|
def test_edit_user(self, _):
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
""" test for app action functionality """
|
""" test for app action functionality """
|
||||||
from unittest.mock import patch
|
from unittest.mock import patch
|
||||||
from tidylib import tidy_document
|
|
||||||
|
|
||||||
from django.contrib.auth.models import AnonymousUser
|
from django.contrib.auth.models import AnonymousUser
|
||||||
from django.template.response import TemplateResponse
|
from django.template.response import TemplateResponse
|
||||||
|
@ -8,6 +7,7 @@ from django.test import TestCase
|
||||||
from django.test.client import RequestFactory
|
from django.test.client import RequestFactory
|
||||||
|
|
||||||
from bookwyrm import models, views
|
from bookwyrm import models, views
|
||||||
|
from bookwyrm.tests.validate_html import validate_html
|
||||||
|
|
||||||
# pylint: disable=unused-argument
|
# pylint: disable=unused-argument
|
||||||
class DirectoryViews(TestCase):
|
class DirectoryViews(TestCase):
|
||||||
|
@ -52,16 +52,7 @@ class DirectoryViews(TestCase):
|
||||||
|
|
||||||
result = view(request)
|
result = view(request)
|
||||||
self.assertIsInstance(result, TemplateResponse)
|
self.assertIsInstance(result, TemplateResponse)
|
||||||
html = result.render()
|
validate_html(result.render())
|
||||||
_, errors = tidy_document(
|
|
||||||
html.content,
|
|
||||||
options={
|
|
||||||
"drop-empty-elements": False,
|
|
||||||
"warn-proprietary-attributes": False,
|
|
||||||
},
|
|
||||||
)
|
|
||||||
if errors:
|
|
||||||
raise Exception(errors)
|
|
||||||
self.assertEqual(result.status_code, 200)
|
self.assertEqual(result.status_code, 200)
|
||||||
|
|
||||||
def test_directory_page_empty(self):
|
def test_directory_page_empty(self):
|
||||||
|
@ -72,10 +63,7 @@ class DirectoryViews(TestCase):
|
||||||
|
|
||||||
result = view(request)
|
result = view(request)
|
||||||
self.assertIsInstance(result, TemplateResponse)
|
self.assertIsInstance(result, TemplateResponse)
|
||||||
html = result.render()
|
validate_html(result.render())
|
||||||
_, errors = tidy_document(html.content, options={"drop-empty-elements": False})
|
|
||||||
if errors:
|
|
||||||
raise Exception(errors)
|
|
||||||
self.assertEqual(result.status_code, 200)
|
self.assertEqual(result.status_code, 200)
|
||||||
|
|
||||||
def test_directory_page_logged_out(self):
|
def test_directory_page_logged_out(self):
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
""" test for app action functionality """
|
""" test for app action functionality """
|
||||||
from unittest.mock import patch
|
from unittest.mock import patch
|
||||||
from tidylib import tidy_document
|
|
||||||
|
|
||||||
from django.contrib.auth.models import AnonymousUser
|
from django.contrib.auth.models import AnonymousUser
|
||||||
from django.http import Http404
|
from django.http import Http404
|
||||||
|
@ -10,6 +9,7 @@ from django.test.client import RequestFactory
|
||||||
from django.utils import timezone
|
from django.utils import timezone
|
||||||
|
|
||||||
from bookwyrm import models, views
|
from bookwyrm import models, views
|
||||||
|
from bookwyrm.tests.validate_html import validate_html
|
||||||
|
|
||||||
|
|
||||||
class GoalViews(TestCase):
|
class GoalViews(TestCase):
|
||||||
|
@ -62,16 +62,7 @@ class GoalViews(TestCase):
|
||||||
request.user = self.local_user
|
request.user = self.local_user
|
||||||
|
|
||||||
result = view(request, self.local_user.localname, self.year)
|
result = view(request, self.local_user.localname, self.year)
|
||||||
html = result.render()
|
validate_html(result.render())
|
||||||
_, errors = tidy_document(
|
|
||||||
html.content,
|
|
||||||
options={
|
|
||||||
"drop-empty-elements": False,
|
|
||||||
"warn-proprietary-attributes": False,
|
|
||||||
},
|
|
||||||
)
|
|
||||||
if errors:
|
|
||||||
raise Exception(errors)
|
|
||||||
self.assertIsInstance(result, TemplateResponse)
|
self.assertIsInstance(result, TemplateResponse)
|
||||||
|
|
||||||
def test_goal_page_anonymous(self):
|
def test_goal_page_anonymous(self):
|
||||||
|
@ -102,16 +93,7 @@ class GoalViews(TestCase):
|
||||||
request.user = self.rat
|
request.user = self.rat
|
||||||
|
|
||||||
result = view(request, self.local_user.localname, timezone.now().year)
|
result = view(request, self.local_user.localname, timezone.now().year)
|
||||||
html = result.render()
|
validate_html(result.render())
|
||||||
_, errors = tidy_document(
|
|
||||||
html.content,
|
|
||||||
options={
|
|
||||||
"drop-empty-elements": False,
|
|
||||||
"warn-proprietary-attributes": False,
|
|
||||||
},
|
|
||||||
)
|
|
||||||
if errors:
|
|
||||||
raise Exception(errors)
|
|
||||||
self.assertIsInstance(result, TemplateResponse)
|
self.assertIsInstance(result, TemplateResponse)
|
||||||
|
|
||||||
def test_goal_page_private(self):
|
def test_goal_page_private(self):
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
""" test for app action functionality """
|
""" test for app action functionality """
|
||||||
import json
|
import json
|
||||||
from unittest.mock import patch
|
from unittest.mock import patch
|
||||||
from tidylib import tidy_document
|
|
||||||
|
|
||||||
from django.core.exceptions import PermissionDenied
|
from django.core.exceptions import PermissionDenied
|
||||||
from django.template.response import TemplateResponse
|
from django.template.response import TemplateResponse
|
||||||
|
@ -10,6 +9,7 @@ from django.test.client import RequestFactory
|
||||||
|
|
||||||
from bookwyrm import forms, models, views
|
from bookwyrm import forms, models, views
|
||||||
from bookwyrm.activitypub import ActivitypubResponse
|
from bookwyrm.activitypub import ActivitypubResponse
|
||||||
|
from bookwyrm.tests.validate_html import validate_html
|
||||||
|
|
||||||
|
|
||||||
@patch("bookwyrm.models.activitypub_mixin.broadcast_task.delay")
|
@patch("bookwyrm.models.activitypub_mixin.broadcast_task.delay")
|
||||||
|
@ -56,16 +56,7 @@ class ShelfViews(TestCase):
|
||||||
is_api.return_value = False
|
is_api.return_value = False
|
||||||
result = view(request, self.local_user.username, shelf.identifier)
|
result = view(request, self.local_user.username, shelf.identifier)
|
||||||
self.assertIsInstance(result, TemplateResponse)
|
self.assertIsInstance(result, TemplateResponse)
|
||||||
html = result.render()
|
validate_html(result.render())
|
||||||
_, errors = tidy_document(
|
|
||||||
html.content,
|
|
||||||
options={
|
|
||||||
"drop-empty-elements": False,
|
|
||||||
"warn-proprietary-attributes": False,
|
|
||||||
},
|
|
||||||
)
|
|
||||||
if errors:
|
|
||||||
raise Exception(errors)
|
|
||||||
self.assertEqual(result.status_code, 200)
|
self.assertEqual(result.status_code, 200)
|
||||||
|
|
||||||
with patch("bookwyrm.views.shelf.is_api_request") as is_api:
|
with patch("bookwyrm.views.shelf.is_api_request") as is_api:
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
""" test for app action functionality """
|
""" test for app action functionality """
|
||||||
from unittest.mock import patch
|
from unittest.mock import patch
|
||||||
from tidylib import tidy_document
|
|
||||||
|
|
||||||
from django.contrib.auth.models import AnonymousUser
|
from django.contrib.auth.models import AnonymousUser
|
||||||
from django.http.response import Http404
|
from django.http.response import Http404
|
||||||
|
@ -10,6 +9,7 @@ from django.test.client import RequestFactory
|
||||||
|
|
||||||
from bookwyrm import models, views
|
from bookwyrm import models, views
|
||||||
from bookwyrm.activitypub import ActivitypubResponse
|
from bookwyrm.activitypub import ActivitypubResponse
|
||||||
|
from bookwyrm.tests.validate_html import validate_html
|
||||||
|
|
||||||
|
|
||||||
class UserViews(TestCase):
|
class UserViews(TestCase):
|
||||||
|
@ -56,16 +56,7 @@ class UserViews(TestCase):
|
||||||
is_api.return_value = False
|
is_api.return_value = False
|
||||||
result = view(request, "mouse")
|
result = view(request, "mouse")
|
||||||
self.assertIsInstance(result, TemplateResponse)
|
self.assertIsInstance(result, TemplateResponse)
|
||||||
html = result.render()
|
validate_html(result.render())
|
||||||
_, errors = tidy_document(
|
|
||||||
html.content,
|
|
||||||
options={
|
|
||||||
"drop-empty-elements": False,
|
|
||||||
"warn-proprietary-attributes": False,
|
|
||||||
},
|
|
||||||
)
|
|
||||||
if errors:
|
|
||||||
raise Exception(errors)
|
|
||||||
self.assertEqual(result.status_code, 200)
|
self.assertEqual(result.status_code, 200)
|
||||||
|
|
||||||
request.user = self.anonymous_user
|
request.user = self.anonymous_user
|
||||||
|
@ -73,16 +64,7 @@ class UserViews(TestCase):
|
||||||
is_api.return_value = False
|
is_api.return_value = False
|
||||||
result = view(request, "mouse")
|
result = view(request, "mouse")
|
||||||
self.assertIsInstance(result, TemplateResponse)
|
self.assertIsInstance(result, TemplateResponse)
|
||||||
html = result.render()
|
validate_html(result.render())
|
||||||
_, errors = tidy_document(
|
|
||||||
html.content,
|
|
||||||
options={
|
|
||||||
"drop-empty-elements": False,
|
|
||||||
"warn-proprietary-attributes": False,
|
|
||||||
},
|
|
||||||
)
|
|
||||||
if errors:
|
|
||||||
raise Exception(errors)
|
|
||||||
self.assertEqual(result.status_code, 200)
|
self.assertEqual(result.status_code, 200)
|
||||||
|
|
||||||
with patch("bookwyrm.views.user.is_api_request") as is_api:
|
with patch("bookwyrm.views.user.is_api_request") as is_api:
|
||||||
|
@ -111,16 +93,7 @@ class UserViews(TestCase):
|
||||||
is_api.return_value = False
|
is_api.return_value = False
|
||||||
result = view(request, "mouse")
|
result = view(request, "mouse")
|
||||||
self.assertIsInstance(result, TemplateResponse)
|
self.assertIsInstance(result, TemplateResponse)
|
||||||
html = result.render()
|
validate_html(result.render())
|
||||||
_, errors = tidy_document(
|
|
||||||
html.content,
|
|
||||||
options={
|
|
||||||
"drop-empty-elements": False,
|
|
||||||
"warn-proprietary-attributes": False,
|
|
||||||
},
|
|
||||||
)
|
|
||||||
if errors:
|
|
||||||
raise Exception(errors)
|
|
||||||
self.assertEqual(result.status_code, 200)
|
self.assertEqual(result.status_code, 200)
|
||||||
|
|
||||||
with patch("bookwyrm.views.user.is_api_request") as is_api:
|
with patch("bookwyrm.views.user.is_api_request") as is_api:
|
||||||
|
@ -151,16 +124,7 @@ class UserViews(TestCase):
|
||||||
is_api.return_value = False
|
is_api.return_value = False
|
||||||
result = view(request, "mouse")
|
result = view(request, "mouse")
|
||||||
self.assertIsInstance(result, TemplateResponse)
|
self.assertIsInstance(result, TemplateResponse)
|
||||||
html = result.render()
|
validate_html(result.render())
|
||||||
_, errors = tidy_document(
|
|
||||||
html.content,
|
|
||||||
options={
|
|
||||||
"drop-empty-elements": False,
|
|
||||||
"warn-proprietary-attributes": False,
|
|
||||||
},
|
|
||||||
)
|
|
||||||
if errors:
|
|
||||||
raise Exception(errors)
|
|
||||||
self.assertEqual(result.status_code, 200)
|
self.assertEqual(result.status_code, 200)
|
||||||
|
|
||||||
with patch("bookwyrm.views.user.is_api_request") as is_api:
|
with patch("bookwyrm.views.user.is_api_request") as is_api:
|
||||||
|
|
Loading…
Reference in a new issue