Example #1
0
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
Example #2
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
Example #3
0
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
Example #4
0
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