improve tests and minor cleanup

This commit is contained in:
Hugh Rundle 2023-11-22 20:04:17 +11:00
parent 8ed4a997f8
commit 6ba7418121
No known key found for this signature in database
GPG key ID: A7E35779918253F9
2 changed files with 17 additions and 3 deletions

View file

@ -22,7 +22,7 @@
</li>
{% if followers_page %}
<li role="menuitem">
{% include 'snippets/remove_follower_button.html' with user=user class="is-fullwidth" blocks=False %}
{% include 'snippets/remove_follower_button.html' with user=user class="is-fullwidth" %}
</li>
{% endif %}
{% endblock %}

View file

@ -173,8 +173,15 @@ class FollowViews(TestCase):
user_subject=self.remote_user, user_object=self.local_user
)
with patch("bookwyrm.models.activitypub_mixin.broadcast_task.apply_async"):
with patch(
"bookwyrm.models.activitypub_mixin.broadcast_task.apply_async"
) as broadcast_mock:
views.delete_follow_request(request)
# did we send the reject activity?
activity = json.loads(broadcast_mock.call_args[1]["args"][1])
self.assertEqual(activity["actor"], self.local_user.remote_id)
self.assertEqual(activity["object"]["object"], rel.user_object.remote_id)
self.assertEqual(activity["type"], "Reject")
# request should be deleted
self.assertEqual(models.UserFollowRequest.objects.filter(id=rel.id).count(), 0)
# follow relationship should not exist
@ -187,8 +194,15 @@ class FollowViews(TestCase):
rel = models.UserFollows.objects.create(
user_subject=self.remote_user, user_object=self.local_user
)
with patch("bookwyrm.models.activitypub_mixin.broadcast_task.apply_async"):
with patch(
"bookwyrm.models.activitypub_mixin.broadcast_task.apply_async"
) as broadcast_mock:
views.remove_follow(request, self.remote_user.id)
# did we send the reject activity?
activity = json.loads(broadcast_mock.call_args[1]["args"][1])
self.assertEqual(activity["actor"], self.local_user.remote_id)
self.assertEqual(activity["object"]["object"], rel.user_object.remote_id)
self.assertEqual(activity["type"], "Reject")
# follow relationship should not exist
self.assertEqual(models.UserFollows.objects.filter(id=rel.id).count(), 0)