Update edition ranks when work is saved

This commit is contained in:
Mouse Reeve
2021-01-11 09:49:32 -08:00
parent 6db64e33e4
commit 83852e29eb
4 changed files with 26 additions and 1 deletions

View File

@ -82,3 +82,19 @@ class Book(TestCase):
self.assertEqual(book.edition_info, 'worm, Glorbish language, 2020')
self.assertEqual(
book.alt_text, 'Test Edition cover (worm, Glorbish language, 2020)')
def test_get_rank(self):
''' sets the data quality index for the book '''
# basic rank
self.assertEqual(self.first_edition.edition_rank, 0)
self.first_edition.description = 'hi'
self.first_edition.save()
self.assertEqual(self.first_edition.edition_rank, 1)
# default edition
self.work.default_edition = self.first_edition
self.work.save()
self.first_edition.refresh_from_db()
self.assertEqual(self.first_edition.edition_rank, 20)