forked from mirrors/bookwyrm
Adds test for shelf
This commit is contained in:
parent
cc1ae270cc
commit
183e76eb2a
2 changed files with 14 additions and 3 deletions
|
@ -1,6 +1,8 @@
|
|||
""" test for app action functionality """
|
||||
import json
|
||||
from unittest.mock import patch
|
||||
from tidylib import tidy_document
|
||||
|
||||
from django.template.response import TemplateResponse
|
||||
from django.test import TestCase
|
||||
from django.test.client import RequestFactory
|
||||
|
@ -53,7 +55,16 @@ class ShelfViews(TestCase):
|
|||
is_api.return_value = False
|
||||
result = view(request, self.local_user.username, shelf.identifier)
|
||||
self.assertIsInstance(result, TemplateResponse)
|
||||
result.render()
|
||||
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)
|
||||
|
||||
with patch("bookwyrm.views.shelf.is_api_request") as is_api:
|
||||
|
|
|
@ -41,7 +41,7 @@ class Goal(View):
|
|||
"year": year,
|
||||
"is_self": request.user == user,
|
||||
}
|
||||
return TemplateResponse(request, "goal.html", data)
|
||||
return TemplateResponse(request, "user/goal.html", data)
|
||||
|
||||
def post(self, request, username, year):
|
||||
"""update or create an annual goal"""
|
||||
|
@ -58,7 +58,7 @@ class Goal(View):
|
|||
"goal": goal,
|
||||
"year": year,
|
||||
}
|
||||
return TemplateResponse(request, "goal.html", data)
|
||||
return TemplateResponse(request, "user/goal.html", data)
|
||||
goal = form.save()
|
||||
|
||||
if request.POST.get("post-status"):
|
||||
|
|
Loading…
Reference in a new issue