forked from mirrors/bookwyrm
Adds meaningful test mock
This commit is contained in:
parent
c918edb622
commit
e91947afbf
1 changed files with 10 additions and 2 deletions
|
@ -25,6 +25,13 @@ class GetStartedViews(TestCase):
|
||||||
local=True,
|
local=True,
|
||||||
localname="mouse",
|
localname="mouse",
|
||||||
)
|
)
|
||||||
|
self.local_user = models.User.objects.create_user(
|
||||||
|
"rat@local.com",
|
||||||
|
"rat@rat.rat",
|
||||||
|
"password",
|
||||||
|
local=True,
|
||||||
|
localname="rat",
|
||||||
|
)
|
||||||
self.book = models.Edition.objects.create(
|
self.book = models.Edition.objects.create(
|
||||||
parent_work=models.Work.objects.create(title="hi"),
|
parent_work=models.Work.objects.create(title="hi"),
|
||||||
title="Example Edition",
|
title="Example Edition",
|
||||||
|
@ -121,13 +128,14 @@ class GetStartedViews(TestCase):
|
||||||
validate_html(result.render())
|
validate_html(result.render())
|
||||||
self.assertEqual(result.status_code, 200)
|
self.assertEqual(result.status_code, 200)
|
||||||
|
|
||||||
@patch("bookwyrm.suggested_users.SuggestedUsers.get_suggestions")
|
|
||||||
def test_users_view_with_query(self, *_):
|
def test_users_view_with_query(self, *_):
|
||||||
"""there are so many views, this just makes sure it LOADS"""
|
"""there are so many views, this just makes sure it LOADS"""
|
||||||
view = views.GetStartedUsers.as_view()
|
view = views.GetStartedUsers.as_view()
|
||||||
request = self.factory.get("?query=rat")
|
request = self.factory.get("?query=rat")
|
||||||
request.user = self.local_user
|
request.user = self.local_user
|
||||||
|
|
||||||
|
with patch("bookwyrm.suggested_users.SuggestedUsers.get_suggestions") as mock:
|
||||||
|
mock.return_value = models.User.objects.all()
|
||||||
result = view(request)
|
result = view(request)
|
||||||
|
|
||||||
self.assertIsInstance(result, TemplateResponse)
|
self.assertIsInstance(result, TemplateResponse)
|
||||||
|
|
Loading…
Reference in a new issue