From 6ba74181214e253924f022b2e537e7772eaadfe1 Mon Sep 17 00:00:00 2001 From: Hugh Rundle Date: Wed, 22 Nov 2023 20:04:17 +1100 Subject: [PATCH] improve tests and minor cleanup --- bookwyrm/templates/snippets/user_options.html | 2 +- bookwyrm/tests/views/test_follow.py | 18 ++++++++++++++++-- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/bookwyrm/templates/snippets/user_options.html b/bookwyrm/templates/snippets/user_options.html index ab028a494..0e15e413a 100644 --- a/bookwyrm/templates/snippets/user_options.html +++ b/bookwyrm/templates/snippets/user_options.html @@ -22,7 +22,7 @@ {% if followers_page %}
  • - {% 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" %}
  • {% endif %} {% endblock %} diff --git a/bookwyrm/tests/views/test_follow.py b/bookwyrm/tests/views/test_follow.py index 8d73a666c..d88a42210 100644 --- a/bookwyrm/tests/views/test_follow.py +++ b/bookwyrm/tests/views/test_follow.py @@ -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)