From 8c5637726bdc89732a0af749076f84302a4d14c7 Mon Sep 17 00:00:00 2001 From: Marnanel Thurman Date: Mon, 3 Aug 2020 20:15:50 +0100 Subject: [PATCH] If get_webfinger() says the status is 0 (i.e. couldn't even connect), fetch() doesn't amend that to 404. test_fetch uses suppress_thread_exceptions, as added in commit 001698cd. --- kepi/sombrero_sendpub/fetch.py | 5 ----- kepi/sombrero_sendpub/tests/test_fetch.py | 9 ++++++--- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/kepi/sombrero_sendpub/fetch.py b/kepi/sombrero_sendpub/fetch.py index 58131f1..9511a2a 100644 --- a/kepi/sombrero_sendpub/fetch.py +++ b/kepi/sombrero_sendpub/fetch.py @@ -175,11 +175,6 @@ def fetch_user(username): result.url, ve, ) - - if result.status==0: - result.status = 404 - result.save() - # but don't re-raise the exception return result diff --git a/kepi/sombrero_sendpub/tests/test_fetch.py b/kepi/sombrero_sendpub/tests/test_fetch.py index 557a4a4..ccbb4ad 100644 --- a/kepi/sombrero_sendpub/tests/test_fetch.py +++ b/kepi/sombrero_sendpub/tests/test_fetch.py @@ -8,6 +8,7 @@ from unittest import skip from django.test import TestCase from kepi.sombrero_sendpub.fetch import fetch_user from kepi.trilby_api.models import RemotePerson +from . import suppress_thread_exceptions import httpretty import logging import requests @@ -173,7 +174,8 @@ class TestFetchUser(TestCase): body = timeout, ) - user = fetch_user(EXAMPLE_USER_URL) + with suppress_thread_exceptions(): + user = fetch_user(EXAMPLE_USER_URL) self.assertEqual( user.status, @@ -196,7 +198,8 @@ class TestFetchUser(TestCase): body = no_such_host, ) - user = fetch_user(EXAMPLE_USER_URL) + with suppress_thread_exceptions(): + user = fetch_user(EXAMPLE_USER_URL) self.assertEqual( user.status, @@ -377,7 +380,7 @@ class TestFetchUser(TestCase): self.assertEqual( user.status, - 404, + 0, ) class TestFetchStatus(TestCase):