From 641ac227866dcee0c740daaea9f73948b172ade1 Mon Sep 17 00:00:00 2001 From: Mouse Reeve Date: Tue, 24 Nov 2020 16:26:28 -0800 Subject: [PATCH] remove outdated tests --- bookwyrm/activitypub/base_activity.py | 2 + .../tests/connectors/test_self_connector.py | 7 ++- bookwyrm/tests/test_remote_user.py | 43 ------------------- 3 files changed, 5 insertions(+), 47 deletions(-) diff --git a/bookwyrm/activitypub/base_activity.py b/bookwyrm/activitypub/base_activity.py index 62fce70b..185fc775 100644 --- a/bookwyrm/activitypub/base_activity.py +++ b/bookwyrm/activitypub/base_activity.py @@ -230,6 +230,8 @@ def image_attachments_formatter(images_json): caption = image.get('name') attachment = models.Attachment(caption=caption) image_field = image_formatter(image) + if not image_field: + continue attachment.image.save(*image_field, save=False) attachments.append(attachment) return attachments diff --git a/bookwyrm/tests/connectors/test_self_connector.py b/bookwyrm/tests/connectors/test_self_connector.py index b80ad202..dd638137 100644 --- a/bookwyrm/tests/connectors/test_self_connector.py +++ b/bookwyrm/tests/connectors/test_self_connector.py @@ -57,10 +57,9 @@ class SelfConnector(TestCase): def test_search_rank(self): results = self.connector.search('Anonymous') - self.assertEqual(len(results), 3) - self.assertEqual(results[0].title, 'Edition of Example Work') - self.assertEqual(results[1].title, 'More Editions') - self.assertEqual(results[2].title, 'Another Edition') + self.assertEqual(len(results), 2) + self.assertEqual(results[0].title, 'More Editions') + self.assertEqual(results[1].title, 'Edition of Example Work') def test_search_default_filter(self): diff --git a/bookwyrm/tests/test_remote_user.py b/bookwyrm/tests/test_remote_user.py index 3af8f59c..febf9f67 100644 --- a/bookwyrm/tests/test_remote_user.py +++ b/bookwyrm/tests/test_remote_user.py @@ -21,50 +21,7 @@ class RemoteUser(TestCase): self.user_data = json.loads(datafile.read_bytes()) - def test_get_remote_user(self): actor = 'https://example.com/users/rat' user = remote_user.get_or_create_remote_user(actor) self.assertEqual(user, self.remote_user) - - - def test_create_remote_user(self): - user = remote_user.create_remote_user(self.user_data) - self.assertFalse(user.local) - self.assertEqual(user.remote_id, 'https://example.com/user/mouse') - self.assertEqual(user.username, 'mouse@example.com') - self.assertEqual(user.name, 'MOUSE?? MOUSE!!') - self.assertEqual(user.inbox, 'https://example.com/user/mouse/inbox') - self.assertEqual(user.outbox, 'https://example.com/user/mouse/outbox') - self.assertEqual(user.shared_inbox, 'https://example.com/inbox') - self.assertEqual( - user.public_key, - self.user_data['publicKey']['publicKeyPem'] - ) - self.assertEqual(user.local, False) - self.assertEqual(user.bookwyrm_user, True) - self.assertEqual(user.manually_approves_followers, False) - - - def test_create_remote_user_missing_inbox(self): - del self.user_data['inbox'] - self.assertRaises( - TypeError, - remote_user.create_remote_user, - self.user_data - ) - - - def test_create_remote_user_missing_outbox(self): - del self.user_data['outbox'] - self.assertRaises( - TypeError, - remote_user.create_remote_user, - self.user_data - ) - - - def test_create_remote_user_default_fields(self): - del self.user_data['manuallyApprovesFollowers'] - user = remote_user.create_remote_user(self.user_data) - self.assertEqual(user.manually_approves_followers, False)