add more tests
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Ivan Schaller 2022-05-11 11:32:29 +02:00
parent 04d1d50d39
commit 48de793c63

View file

@ -1,5 +1,9 @@
import os
import shutil
from pathlib import Path
import mangadlp.main as MdlpMain
from mangadlp.api.mangadex import Mangadex
def test_readin_list():
@ -13,8 +17,57 @@ def test_readin_list():
]
def check_api():
def test_check_api():
url = "https://mangadex.org/title/a96676e5-8ae2-425e-b549-7f15dd34a6d8/komi-san-wa-komyushou-desu"
test = MdlpMain.check_api(url)
assert test == eval(mangadlp.api.mangadex.Mangadex)
assert test == Mangadex
def test_full():
url = "https://mangadex.org/title/a96676e5-8ae2-425e-b549-7f15dd34a6d8/komi-san-wa-komyushou-desu"
lang = "en"
chapters = "1"
readlist = ""
list_chapters = False
nocbz = False
forcevol = False
download_path = "tests"
download_wait = 1
verbose = False
manga_path = Path("tests/Komi-san wa Komyushou Desu")
chapter_path = Path("tests/Komi-san wa Komyushou Desu/Ch. 1 - A Normal Person.cbz")
MdlpMain.main(
url,
lang,
chapters,
readlist,
list_chapters,
nocbz,
forcevol,
download_path,
download_wait,
verbose,
)
assert manga_path.exists()
assert chapter_path.exists()
# cleanup
shutil.rmtree(manga_path, ignore_errors=True)
def test_full_with_input():
url = "https://mangadex.org/title/a96676e5-8ae2-425e-b549-7f15dd34a6d8/komi-san-wa-komyushou-desu"
lang = "en"
chapters = "1"
download_path = "tests"
manga_path = Path("tests/Komi-san wa Komyushou Desu")
chapter_path = Path("tests/Komi-san wa Komyushou Desu/Ch. 1 - A Normal Person.cbz")
command_args = f"-u {url} -l {lang} -c {chapters} --path {download_path}"
script_path = "manga-dlp.py"
os.system(f"python3 {script_path} {command_args}")
assert manga_path.exists()
assert chapter_path.exists()
# cleanup
shutil.rmtree(manga_path, ignore_errors=True)