mirror of
https://github.com/bookwyrm-social/bookwyrm.git
synced 2024-12-18 06:06:34 +00:00
Updates user model test
This commit is contained in:
parent
e4b5890992
commit
1e675384bc
1 changed files with 7 additions and 6 deletions
|
@ -5,11 +5,12 @@ from django.test import TestCase
|
||||||
import responses
|
import responses
|
||||||
|
|
||||||
from bookwyrm import models
|
from bookwyrm import models
|
||||||
from bookwyrm.settings import DOMAIN
|
from bookwyrm.settings import USE_HTTPS, DOMAIN
|
||||||
|
|
||||||
# pylint: disable=missing-class-docstring
|
# pylint: disable=missing-class-docstring
|
||||||
# pylint: disable=missing-function-docstring
|
# pylint: disable=missing-function-docstring
|
||||||
class User(TestCase):
|
class User(TestCase):
|
||||||
|
protocol = "https://" if USE_HTTPS else "http://"
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"):
|
with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"):
|
||||||
self.user = models.User.objects.create_user(
|
self.user = models.User.objects.create_user(
|
||||||
|
@ -24,13 +25,13 @@ class User(TestCase):
|
||||||
|
|
||||||
def test_computed_fields(self):
|
def test_computed_fields(self):
|
||||||
"""username instead of id here"""
|
"""username instead of id here"""
|
||||||
expected_id = "https://%s/user/mouse" % DOMAIN
|
expected_id = f"{self.protocol}{DOMAIN}/user/mouse"
|
||||||
self.assertEqual(self.user.remote_id, expected_id)
|
self.assertEqual(self.user.remote_id, expected_id)
|
||||||
self.assertEqual(self.user.username, "mouse@%s" % DOMAIN)
|
self.assertEqual(self.user.username, f"mouse@{DOMAIN}")
|
||||||
self.assertEqual(self.user.localname, "mouse")
|
self.assertEqual(self.user.localname, "mouse")
|
||||||
self.assertEqual(self.user.shared_inbox, "https://%s/inbox" % DOMAIN)
|
self.assertEqual(self.user.shared_inbox, f"{self.protocol}{DOMAIN}/inbox")
|
||||||
self.assertEqual(self.user.inbox, "%s/inbox" % expected_id)
|
self.assertEqual(self.user.inbox, f"{expected_id}/inbox")
|
||||||
self.assertEqual(self.user.outbox, "%s/outbox" % expected_id)
|
self.assertEqual(self.user.outbox, f"{expected_id}/outbox")
|
||||||
self.assertIsNotNone(self.user.key_pair.private_key)
|
self.assertIsNotNone(self.user.key_pair.private_key)
|
||||||
self.assertIsNotNone(self.user.key_pair.public_key)
|
self.assertIsNotNone(self.user.key_pair.public_key)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue