Esempio n. 1
0
def setup_inject(peewee_database_storage):
    inject.clear_and_configure(
        lambda binder: binder.bind(SqliteDatabase, peewee_database_storage).
        bind_to_constructor("FilesystemMonitor", MagicMock()
                            ).bind_to_constructor(Library, MagicMock()))

    yield
    inject.clear()
Esempio n. 2
0
def setup_inject(peewee_database):
    inject.clear_and_configure(
        lambda binder: binder.bind(SqliteDatabase, peewee_database).
        bind_to_constructor("FilesystemMonitor", MagicMock(
        )).bind_to_constructor(GstPlayer, MagicMock()).bind_to_constructor(
            ApplicationSettings, MagicMock()).bind_to_constructor(
                Library, lambda: Library()).bind_to_constructor(
                    Settings, lambda: Settings()))

    yield
    inject.clear()
Esempio n. 3
0
def test_deleted_book_removed_from_last_played_book_if_necessary(
        peewee_database):
    from cozy.model.book import Book
    from cozy.model.settings import Settings

    settings = Settings()
    inject.clear_and_configure(lambda binder: binder.bind(
        SqliteDatabase, peewee_database) and binder.bind(Settings, settings))
    book = Book(peewee_database, 1)

    settings.last_played_book = book.db_object
    book._on_chapter_event("chapter-deleted", book.chapters[0])

    assert settings.last_played_book == None
Esempio n. 4
0
def setup_inject(peewee_database_storage):
    inject.clear_and_configure(
        lambda binder: binder.bind(SqliteDatabase, peewee_database_storage))
    yield
    inject.clear()
Esempio n. 5
0
def setup_inject(peewee_database):
    inject.clear_and_configure(lambda binder: binder.bind(
        SqliteDatabase, peewee_database).bind_to_constructor(
            ApplicationSettings, lambda: ApplicationSettingsMock()))
    yield
    inject.clear()