kopia lustrzana https://gitlab.com/marnanel/chapeau
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
.
status-serialisers
rodzic
0ab2dae738
commit
8c5637726b
|
@ -175,11 +175,6 @@ def fetch_user(username):
|
||||||
result.url,
|
result.url,
|
||||||
ve,
|
ve,
|
||||||
)
|
)
|
||||||
|
|
||||||
if result.status==0:
|
|
||||||
result.status = 404
|
|
||||||
result.save()
|
|
||||||
|
|
||||||
# but don't re-raise the exception
|
# but don't re-raise the exception
|
||||||
|
|
||||||
return result
|
return result
|
||||||
|
|
|
@ -8,6 +8,7 @@ from unittest import skip
|
||||||
from django.test import TestCase
|
from django.test import TestCase
|
||||||
from kepi.sombrero_sendpub.fetch import fetch_user
|
from kepi.sombrero_sendpub.fetch import fetch_user
|
||||||
from kepi.trilby_api.models import RemotePerson
|
from kepi.trilby_api.models import RemotePerson
|
||||||
|
from . import suppress_thread_exceptions
|
||||||
import httpretty
|
import httpretty
|
||||||
import logging
|
import logging
|
||||||
import requests
|
import requests
|
||||||
|
@ -173,7 +174,8 @@ class TestFetchUser(TestCase):
|
||||||
body = timeout,
|
body = timeout,
|
||||||
)
|
)
|
||||||
|
|
||||||
user = fetch_user(EXAMPLE_USER_URL)
|
with suppress_thread_exceptions():
|
||||||
|
user = fetch_user(EXAMPLE_USER_URL)
|
||||||
|
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
user.status,
|
user.status,
|
||||||
|
@ -196,7 +198,8 @@ class TestFetchUser(TestCase):
|
||||||
body = no_such_host,
|
body = no_such_host,
|
||||||
)
|
)
|
||||||
|
|
||||||
user = fetch_user(EXAMPLE_USER_URL)
|
with suppress_thread_exceptions():
|
||||||
|
user = fetch_user(EXAMPLE_USER_URL)
|
||||||
|
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
user.status,
|
user.status,
|
||||||
|
@ -377,7 +380,7 @@ class TestFetchUser(TestCase):
|
||||||
|
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
user.status,
|
user.status,
|
||||||
404,
|
0,
|
||||||
)
|
)
|
||||||
|
|
||||||
class TestFetchStatus(TestCase):
|
class TestFetchStatus(TestCase):
|
||||||
|
|
Ładowanie…
Reference in New Issue