Use more f strings in status models test file

This commit is contained in:
Mouse Reeve 2021-10-01 14:24:11 -07:00
parent 8461fe5ec3
commit 7ff040470f

View file

@ -52,7 +52,7 @@ class Status(TestCase):
def test_status_generated_fields(self, *_):
"""setting remote id"""
status = models.Status.objects.create(content="bleh", user=self.local_user)
expected_id = "https://%s/user/mouse/status/%d" % (settings.DOMAIN, status.id)
expected_id = f"https://{settings.DOMAIN}/user/mouse/status/{status.id}"
self.assertEqual(status.remote_id, expected_id)
self.assertEqual(status.privacy, "public")
@ -104,7 +104,7 @@ class Status(TestCase):
)
replies = parent.to_replies()
self.assertEqual(replies["id"], "%s/replies" % parent.remote_id)
self.assertEqual(replies["id"], f"{parent.remote_id}/replies")
self.assertEqual(replies["totalItems"], 2)
def test_status_to_activity(self, *_):
@ -168,7 +168,7 @@ class Status(TestCase):
self.assertEqual(activity["id"], status.remote_id)
self.assertEqual(
activity["content"],
'mouse test content <a href="%s">"Test Edition"</a>' % self.book.remote_id,
f'mouse test content <a href="{self.book.remote_id}">"Test Edition"</a>',
)
self.assertEqual(len(activity["tag"]), 2)
self.assertEqual(activity["type"], "Note")
@ -177,7 +177,7 @@ class Status(TestCase):
self.assertEqual(activity["attachment"][0].type, "Document")
self.assertEqual(
activity["attachment"][0].url,
"https://%s%s" % (settings.DOMAIN, self.book.cover.url),
f"https://{settings.DOMAIN}{self.book.cover.url}",
)
self.assertEqual(activity["attachment"][0].name, "Test Edition")
@ -202,13 +202,12 @@ class Status(TestCase):
self.assertEqual(activity["type"], "Note")
self.assertEqual(
activity["content"],
'test content<p>(comment on <a href="%s">"Test Edition"</a>)</p>'
% self.book.remote_id,
f'test content<p>(comment on <a href="{self.book.remote_id}">"Test Edition"</a>)</p>',
)
self.assertEqual(activity["attachment"][0].type, "Document")
self.assertEqual(
activity["attachment"][0].url,
"https://%s%s" % (settings.DOMAIN, self.book.cover.url),
f"https://{settings.DOMAIN}{self.book.cover.url}",
)
self.assertEqual(activity["attachment"][0].name, "Test Edition")
@ -240,13 +239,12 @@ class Status(TestCase):
self.assertEqual(activity["type"], "Note")
self.assertEqual(
activity["content"],
'a sickening sense <p>-- <a href="%s">"Test Edition"</a></p>'
"test content" % self.book.remote_id,
f'a sickening sense <p>-- <a href="{self.book.remote_id}">"Test Edition"</a></p>test content',
)
self.assertEqual(activity["attachment"][0].type, "Document")
self.assertEqual(
activity["attachment"][0].url,
"https://%s%s" % (settings.DOMAIN, self.book.cover.url),
f"https://{settings.DOMAIN}{self.book.cover.url}",
)
self.assertEqual(activity["attachment"][0].name, "Test Edition")
@ -281,13 +279,13 @@ class Status(TestCase):
self.assertEqual(activity["type"], "Article")
self.assertEqual(
activity["name"],
'Review of "%s" (3 stars): Review\'s name' % self.book.title,
f'Review of "{self.book.title}" (3 stars): Review\'s name',
)
self.assertEqual(activity["content"], "test content")
self.assertEqual(activity["attachment"][0].type, "Document")
self.assertEqual(
activity["attachment"][0].url,
"https://%s%s" % (settings.DOMAIN, self.book.cover.url),
f"https://{settings.DOMAIN}{self.book.cover.url}",
)
self.assertEqual(activity["attachment"][0].name, "Test Edition")
@ -303,13 +301,13 @@ class Status(TestCase):
self.assertEqual(activity["id"], status.remote_id)
self.assertEqual(activity["type"], "Article")
self.assertEqual(
activity["name"], 'Review of "%s": Review name' % self.book.title
activity["name"], f'Review of "{self.book.title}": Review name'
)
self.assertEqual(activity["content"], "test content")
self.assertEqual(activity["attachment"][0].type, "Document")
self.assertEqual(
activity["attachment"][0].url,
"https://%s%s" % (settings.DOMAIN, self.book.cover.url),
f"https://{settings.DOMAIN}{self.book.cover.url}",
)
self.assertEqual(activity["attachment"][0].name, "Test Edition")
@ -325,13 +323,12 @@ class Status(TestCase):
self.assertEqual(activity["type"], "Note")
self.assertEqual(
activity["content"],
'rated <em><a href="%s">%s</a></em>: 3 stars'
% (self.book.remote_id, self.book.title),
f'rated <em><a href="{self.book.remote_id}">{self.book.title}</a></em>: 3 stars',
)
self.assertEqual(activity["attachment"][0].type, "Document")
self.assertEqual(
activity["attachment"][0].url,
"https://%s%s" % (settings.DOMAIN, self.book.cover.url),
f"https://{settings.DOMAIN}{self.book.cover.url}",
)
self.assertEqual(activity["attachment"][0].name, "Test Edition")