forked from mirrors/bookwyrm
Edit user test mocks
This commit is contained in:
parent
c23f341980
commit
5d2324a4a0
2 changed files with 15 additions and 14 deletions
|
@ -15,6 +15,7 @@ from django.test.client import RequestFactory
|
||||||
from bookwyrm import forms, models, views
|
from bookwyrm import forms, models, views
|
||||||
|
|
||||||
|
|
||||||
|
@patch("bookwyrm.suggested_users.remove_user_task.delay")
|
||||||
class EditUserViews(TestCase):
|
class EditUserViews(TestCase):
|
||||||
"""view user and edit profile"""
|
"""view user and edit profile"""
|
||||||
|
|
||||||
|
@ -33,19 +34,19 @@ class EditUserViews(TestCase):
|
||||||
"rat@local.com", "rat@rat.rat", "password", local=True, localname="rat"
|
"rat@local.com", "rat@rat.rat", "password", local=True, localname="rat"
|
||||||
)
|
)
|
||||||
|
|
||||||
self.book = models.Edition.objects.create(title="test")
|
self.book = models.Edition.objects.create(title="test")
|
||||||
with patch("bookwyrm.models.activitypub_mixin.broadcast_task.delay"):
|
with patch("bookwyrm.models.activitypub_mixin.broadcast_task.delay"):
|
||||||
models.ShelfBook.objects.create(
|
models.ShelfBook.objects.create(
|
||||||
book=self.book,
|
book=self.book,
|
||||||
user=self.local_user,
|
user=self.local_user,
|
||||||
shelf=self.local_user.shelf_set.first(),
|
shelf=self.local_user.shelf_set.first(),
|
||||||
)
|
)
|
||||||
|
|
||||||
models.SiteSettings.objects.create()
|
models.SiteSettings.objects.create()
|
||||||
self.anonymous_user = AnonymousUser
|
self.anonymous_user = AnonymousUser
|
||||||
self.anonymous_user.is_authenticated = False
|
self.anonymous_user.is_authenticated = False
|
||||||
|
|
||||||
def test_edit_user_page(self):
|
def test_edit_user_page(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.EditUser.as_view()
|
view = views.EditUser.as_view()
|
||||||
request = self.factory.get("")
|
request = self.factory.get("")
|
||||||
|
@ -55,7 +56,7 @@ class EditUserViews(TestCase):
|
||||||
result.render()
|
result.render()
|
||||||
self.assertEqual(result.status_code, 200)
|
self.assertEqual(result.status_code, 200)
|
||||||
|
|
||||||
def test_edit_user(self):
|
def test_edit_user(self, _):
|
||||||
"""use a form to update a user"""
|
"""use a form to update a user"""
|
||||||
view = views.EditUser.as_view()
|
view = views.EditUser.as_view()
|
||||||
form = forms.EditUserForm(instance=self.local_user)
|
form = forms.EditUserForm(instance=self.local_user)
|
||||||
|
@ -74,7 +75,7 @@ class EditUserViews(TestCase):
|
||||||
self.assertEqual(self.local_user.name, "New Name")
|
self.assertEqual(self.local_user.name, "New Name")
|
||||||
self.assertEqual(self.local_user.email, "wow@email.com")
|
self.assertEqual(self.local_user.email, "wow@email.com")
|
||||||
|
|
||||||
def test_edit_user_avatar(self):
|
def test_edit_user_avatar(self, _):
|
||||||
"""use a form to update a user"""
|
"""use a form to update a user"""
|
||||||
view = views.EditUser.as_view()
|
view = views.EditUser.as_view()
|
||||||
form = forms.EditUserForm(instance=self.local_user)
|
form = forms.EditUserForm(instance=self.local_user)
|
||||||
|
@ -101,7 +102,7 @@ class EditUserViews(TestCase):
|
||||||
self.assertEqual(self.local_user.avatar.width, 120)
|
self.assertEqual(self.local_user.avatar.width, 120)
|
||||||
self.assertEqual(self.local_user.avatar.height, 120)
|
self.assertEqual(self.local_user.avatar.height, 120)
|
||||||
|
|
||||||
def test_crop_avatar(self):
|
def test_crop_avatar(self, _):
|
||||||
"""reduce that image size"""
|
"""reduce that image size"""
|
||||||
image_file = pathlib.Path(__file__).parent.joinpath(
|
image_file = pathlib.Path(__file__).parent.joinpath(
|
||||||
"../../static/images/no_cover.jpg"
|
"../../static/images/no_cover.jpg"
|
||||||
|
@ -113,7 +114,7 @@ class EditUserViews(TestCase):
|
||||||
image_result = Image.open(result)
|
image_result = Image.open(result)
|
||||||
self.assertEqual(image_result.size, (120, 120))
|
self.assertEqual(image_result.size, (120, 120))
|
||||||
|
|
||||||
def test_delete_user_page(self):
|
def test_delete_user_page(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.DeleteUser.as_view()
|
view = views.DeleteUser.as_view()
|
||||||
request = self.factory.get("")
|
request = self.factory.get("")
|
||||||
|
@ -124,7 +125,7 @@ class EditUserViews(TestCase):
|
||||||
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")
|
||||||
def test_delete_user(self, _):
|
def test_delete_user(self, *_):
|
||||||
"""use a form to update a user"""
|
"""use a form to update a user"""
|
||||||
view = views.DeleteUser.as_view()
|
view = views.DeleteUser.as_view()
|
||||||
form = forms.DeleteUserForm()
|
form = forms.DeleteUserForm()
|
||||||
|
|
|
@ -163,7 +163,7 @@ class FederationViews(TestCase):
|
||||||
"""load a json file with a list of servers to block"""
|
"""load a json file with a list of servers to block"""
|
||||||
server = models.FederatedServer.objects.create(server_name="hi.there.com")
|
server = models.FederatedServer.objects.create(server_name="hi.there.com")
|
||||||
self.remote_user.federated_server = server
|
self.remote_user.federated_server = server
|
||||||
self.remote_user.save()
|
self.remote_user.save(update_fields=["federated_server"])
|
||||||
|
|
||||||
data = [
|
data = [
|
||||||
{"instance": "server.name", "url": "https://explanation.url"}, # new server
|
{"instance": "server.name", "url": "https://explanation.url"}, # new server
|
||||||
|
|
Loading…
Reference in a new issue