def test_progress_should_be_zero_for_unstarted_book(peewee_database): from cozy.model.book import Book book = Book(peewee_database, 1) book.position = 0 assert book.progress == 0
def test_progress_should_be_100_for_finished_book(peewee_database): from cozy.model.book import Book book = Book(peewee_database, 1) book.position = -1 assert book.progress == book.duration
def test_setting_position_updates_in_book_object_and_database(peewee_database): from cozy.db.book import Book as BookModel from cozy.model.book import Book book = Book(peewee_database, 1) book.position = 42 assert book.position == 42 assert BookModel.get_by_id(1).position == 42
def test_progress_return_progress_for_started_book(peewee_database): from cozy.model.book import Book book = Book(peewee_database, 1) chapter = book.chapters[0] chapter.position = 42 * 1000000000 book.position = chapter.id assert book.progress == 42