Exemplo n.º 1
0
def test_prepare_db_objects_raises_not_implemented_for_multi_chapter_file(mocker):
    from cozy.model.library import Library
    from cozy.media.media_file import MediaFile
    from cozy.media.chapter import Chapter

    library = Library()

    chapter = Chapter("New Chapter", 0)
    media_file = MediaFile(book_name="Test Book New",
                           author="New Author2",
                           reader="New Reader",
                           disk=999,
                           track_number=999,
                           length=1234567,
                           cover=b"cover",
                           path="New test File",
                           modified=1234567,
                           chapters=[chapter, chapter])

    with pytest.raises(NotImplementedError):
        res_dict = library._prepare_db_objects([media_file])
        list(res_dict)
Exemplo n.º 2
0
def test_prepare_db_objects_creates_new_book(mocker):
    from cozy.model.library import Library
    from cozy.media.media_file import MediaFile
    from cozy.media.chapter import Chapter

    library = Library()
    spy = mocker.spy(library, "_create_book_db_object")

    chapter = Chapter("New Chapter", 0)
    media_file = MediaFile(book_name="Test Book New",
                           author="New Author2",
                           reader="New Reader",
                           disk=999,
                           track_number=999,
                           length=1234567,
                           cover=b"cover",
                           path="New test File",
                           modified=1234567,
                           chapters=[chapter])

    res_dict = library._prepare_db_objects([media_file])

    assert len(list(res_dict)) == 1
    spy.assert_called_once()
Exemplo n.º 3
0
def test_prepare_db_objects_skips_none():
    from cozy.model.library import Library
    library = Library()

    library._prepare_db_objects([None, None, None])