mirror of
https://github.com/bookwyrm-social/bookwyrm.git
synced 2024-11-22 01:21:07 +00:00
test_quotation_page_serialization: add test with no position
This commit is contained in:
parent
df78cc64a6
commit
8733369605
2 changed files with 7 additions and 5 deletions
|
@ -392,7 +392,7 @@ class Quotation(BookStatus):
|
|||
def _format_position(self) -> Optional[str]:
|
||||
"""serialize page position"""
|
||||
beg = self.position
|
||||
end = self.endposition or 0
|
||||
end = self.endposition
|
||||
if self.position_mode != "PG" or not beg:
|
||||
return None
|
||||
return f"pp. {beg}-{end}" if end else f"p. {beg}"
|
||||
|
|
|
@ -341,6 +341,7 @@ class Status(TestCase):
|
|||
"""serialization of quotation page position"""
|
||||
tests = [
|
||||
("single pos", "7", "", "p. 7"),
|
||||
("missing beg", "", "10", None),
|
||||
("page range", "7", "10", "pp. 7-10"),
|
||||
("page range roman", "xv", "xvi", "pp. xv-xvi"),
|
||||
("page range reverse", "14", "10", "pp. 14-10"),
|
||||
|
@ -357,10 +358,11 @@ class Status(TestCase):
|
|||
position_mode="PG",
|
||||
)
|
||||
activity = status.to_activity(pure=True)
|
||||
self.assertRegex(
|
||||
activity["content"],
|
||||
f'^<p>"my quote"</p> <p>— <a .+</a>, {pages}</p>$',
|
||||
)
|
||||
if pages:
|
||||
expect_re = f'^<p>"my quote"</p> <p>— <a .+</a>, {pages}</p>$'
|
||||
else:
|
||||
expect_re = '^<p>"my quote"</p> <p>— <a .+</a></p>$'
|
||||
self.assertRegex(activity["content"], expect_re)
|
||||
|
||||
def test_review_to_activity(self, *_):
|
||||
"""subclass of the base model version with a "pure" serializer"""
|
||||
|
|
Loading…
Reference in a new issue