Exemplo n.º 1
0
def test_comic_archive_compress_exception() -> None:
    old_format = "CBR"
    _, _, _, settings = _setup_compress(old_format)
    nag_about_gifs = False
    TMP_ROOT.mkdir(exist_ok=True)
    path = TMP_ROOT / "XXXXX"
    args = (path, old_format, settings, nag_about_gifs)
    excepted = False
    try:
        Comic.comic_archive_compress(args)
    except Exception:
        excepted = True
        pass
    assert excepted
    _teardown()
Exemplo n.º 2
0
def test_comic_archive_compress_tmp_path() -> None:
    old_format = "CBZ"
    old_path, old_size, optimized_archive, settings = _setup_compress(
        old_format)
    nag_about_gifs = False
    args = (old_path, old_format, settings, nag_about_gifs)
    assert optimized_archive.is_file()
    res = Comic.comic_archive_compress(args)
    assert optimized_archive.is_file()
    assert res.bytes_in == old_size
    assert res.bytes_out == TEST_ZIP_SIZE
    assert TEST_CBZ.stat().st_size == TEST_ZIP_SIZE
    _teardown()
Exemplo n.º 3
0
def test_comic_archive_compress() -> None:
    old_format = "CBR"
    old_path, old_size, optimized_archive, settings = _setup_compress(
        old_format)
    nag_about_gifs = False
    args = (old_path, old_format, settings, nag_about_gifs, TEST_COMMENT)
    assert not optimized_archive.is_file()
    res = Comic.comic_archive_compress(args)
    assert optimized_archive.is_file()
    assert res.bytes_in == old_size
    assert res.bytes_out == COMMENT_ZIP_SIZE
    assert TEST_CBZ.stat().st_size == COMMENT_ZIP_SIZE
    with zipfile.ZipFile(res.final_path, "r") as zf:
        assert zf.comment == TEST_COMMENT
    _teardown()