From ebc06802884357fc7cb13a1090584b0990fcde07 Mon Sep 17 00:00:00 2001 From: Mouse Reeve Date: Tue, 3 Aug 2021 12:21:11 -0700 Subject: [PATCH] Fixes logic error in detecting changed fields when serializing --- bookwyrm/models/fields.py | 2 +- bookwyrm/tests/activitypub/test_base_activity.py | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/bookwyrm/models/fields.py b/bookwyrm/models/fields.py index 02efe675..b58f8174 100644 --- a/bookwyrm/models/fields.py +++ b/bookwyrm/models/fields.py @@ -80,7 +80,7 @@ class ActivitypubFieldMixin: return False # the field is unchanged - if getattr(instance, self.name) == formatted: + if hasattr(instance, self.name) and getattr(instance, self.name) == formatted: return False setattr(instance, self.name, formatted) diff --git a/bookwyrm/tests/activitypub/test_base_activity.py b/bookwyrm/tests/activitypub/test_base_activity.py index b3f16add..0758fe99 100644 --- a/bookwyrm/tests/activitypub/test_base_activity.py +++ b/bookwyrm/tests/activitypub/test_base_activity.py @@ -21,6 +21,7 @@ from bookwyrm import models @patch("bookwyrm.activitystreams.ActivityStream.add_status") @patch("bookwyrm.suggested_users.rerank_user_task.delay") +@patch("bookwyrm.suggested_users.remove_user_task.delay") @patch("bookwyrm.suggested_users.rerank_suggestions_task.delay") class BaseActivity(TestCase): """the super class for model-linked activitypub dataclasses"""