mirror of
https://github.com/bookwyrm-social/bookwyrm.git
synced 2024-11-23 01:51:08 +00:00
Fixes peers endpoint
This commit is contained in:
parent
9d886254d8
commit
09e49c70ed
2 changed files with 23 additions and 4 deletions
|
@ -10,7 +10,7 @@ from django.test.client import RequestFactory
|
|||
from bookwyrm import models, views
|
||||
|
||||
|
||||
class UserViews(TestCase):
|
||||
class WellknownViews(TestCase):
|
||||
"""view user and edit profile"""
|
||||
|
||||
def setUp(self):
|
||||
|
@ -95,3 +95,22 @@ class UserViews(TestCase):
|
|||
self.assertIsInstance(result, JsonResponse)
|
||||
self.assertEqual(data["stats"]["user_count"], 2)
|
||||
self.assertEqual(models.User.objects.count(), 3)
|
||||
|
||||
def test_peers(self):
|
||||
"""who's federating with whom"""
|
||||
models.FederatedServer.objects.create(
|
||||
server_name="test.server",
|
||||
status="federated",
|
||||
)
|
||||
models.FederatedServer.objects.create(
|
||||
server_name="another.test.server",
|
||||
status="blocked",
|
||||
)
|
||||
request = self.factory.get("")
|
||||
request.user = self.anonymous_user
|
||||
|
||||
result = views.peers(request)
|
||||
data = json.loads(result.getvalue())
|
||||
self.assertIsInstance(result, JsonResponse)
|
||||
self.assertEqual(len(data), 1)
|
||||
self.assertEqual(data[0], "test.server")
|
||||
|
|
|
@ -95,7 +95,7 @@ def instance_info(_):
|
|||
status_count = models.Status.objects.filter(user__local=True, deleted=False).count()
|
||||
|
||||
site = models.SiteSettings.get()
|
||||
logo_path = site.logo_small or "images/logo-small.png"
|
||||
logo_path = site.logo or "images/logo.png"
|
||||
logo = f"{MEDIA_FULL_URL}{logo_path}"
|
||||
return JsonResponse(
|
||||
{
|
||||
|
@ -120,8 +120,8 @@ def instance_info(_):
|
|||
@require_GET
|
||||
def peers(_):
|
||||
"""list of federated servers this instance connects with"""
|
||||
names = models.FederatedServer.objects.values_list(
|
||||
"server_name", flat=True, status="federated"
|
||||
names = models.FederatedServer.objects.filter(status="federated").values_list(
|
||||
"server_name", flat=True
|
||||
)
|
||||
return JsonResponse(list(names), safe=False)
|
||||
|
||||
|
|
Loading…
Reference in a new issue