From 6b39052fcca4aebba6f9d9e4d049e4afd1b0d66d Mon Sep 17 00:00:00 2001 From: Zach Flanders Date: Tue, 25 Apr 2023 07:17:23 -0500 Subject: [PATCH] Adding test for sort_title population --- bookwyrm/tests/models/test_book_model.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/bookwyrm/tests/models/test_book_model.py b/bookwyrm/tests/models/test_book_model.py index 33854b3d6..50ff8c7e1 100644 --- a/bookwyrm/tests/models/test_book_model.py +++ b/bookwyrm/tests/models/test_book_model.py @@ -132,3 +132,16 @@ class Book(TestCase): self.assertIsNotNone(book.cover_bw_book_xlarge_jpg.url) self.assertIsNotNone(book.cover_bw_book_xxlarge_webp.url) self.assertIsNotNone(book.cover_bw_book_xxlarge_jpg.url) + + def test_populate_sort_title(self): + """The sort title should remove the initial article on save""" + books = ( + models.Edition.objects.create( + title=f"{article} Test Edition", languages=[langauge] + ) + for langauge, articles in settings.LANGUAGE_ARTICLES.items() + for article in article + ) + self.assertEqual( + all([book.sort_title == "Test Edition" for book in books]) + )