Added testing

This commit is contained in:
Firq 2024-10-20 21:38:22 +02:00
parent 821251b77c
commit 56c1d5427a
Signed by: Firq
GPG key ID: 3ACC61C8CEC83C20
8 changed files with 151 additions and 8 deletions

15
tests/conftest.py Normal file
View file

@ -0,0 +1,15 @@
import pathlib
import shutil
import pytest
@pytest.fixture(scope="function")
def path_images():
path = pathlib.Path(__file__).parent / "test_path_images"
yield path
shutil.rmtree(path)
@pytest.fixture(scope="function")
def path_output():
path = pathlib.Path(__file__).parent / "test_path_output"
yield path
shutil.rmtree(path)

36
tests/test_01_class.py Normal file
View file

@ -0,0 +1,36 @@
from pathlib import Path
from skyeweave import SkyeWeave
def test_servantid_create(path_images: Path, path_output: Path):
test_id = 70
test_weaver = SkyeWeave(
test_id,
output=path_output,
assets=path_images
)
assert test_weaver.output_folder == path_output / str(test_id)
assert path_output.exists()
assert (path_output / str(test_id)).exists()
assert test_weaver.image_folder == path_images / str(test_id)
assert path_images.exists()
assert (path_images / str(test_id)).exists()
def test_charaid_create(path_images: Path, path_output: Path):
test_id = 3013002
test_weaver = SkyeWeave(
test_id,
output=path_output,
assets=path_images
)
assert test_weaver.output_folder == path_output / "manual"
assert path_output.exists()
assert (path_output / "manual").exists()
assert test_weaver.image_folder == path_images / "manual"
assert path_images.exists()
assert (path_images / "manual").exists()

66
tests/test_02_download.py Normal file
View file

@ -0,0 +1,66 @@
from pathlib import Path
from skyeweave import SkyeWeave
def test_servantid_download(path_images: Path, path_output: Path):
test_id = 70
test_weaver = SkyeWeave(
test_id,
output=path_output,
assets=path_images
)
test_weaver.download()
expected_path = path_images / str(test_id)
expected_dirs = [ "3013000", "3013001", "3013002", "3013300", "1098204200", "1098264100", "1098290800" ]
dirs = [f for f in expected_path.iterdir() if f.is_dir()]
assert set([d.name for d in dirs]) == set(expected_dirs)
for d in dirs:
expected_files = ["0.png", "1.png"]
files = [f.name for f in d.iterdir() if f.is_file()]
assert set(files) == set(expected_files)
def test_servantid_download_filter(path_images: Path, path_output: Path):
test_id = 70
test_weaver = SkyeWeave(
test_id,
filters=[ 3013000, 3013001, 1098290800],
output=path_output,
assets=path_images
)
test_weaver.download()
expected_path = path_images / str(test_id)
expected_dirs = [ "3013000", "3013001", "1098290800" ]
dirs =[f for f in expected_path.iterdir() if f.is_dir()]
assert set([d.name for d in dirs]) == set(expected_dirs)
for d in dirs:
expected_files = ["0.png", "1.png"]
files = [f.name for f in d.iterdir() if f.is_file()]
assert set(files) == set(expected_files)
def test_charaid_download(path_images: Path, path_output: Path):
test_id = 3013000
test_weaver = SkyeWeave(
test_id,
output=path_output,
assets=path_images
)
test_weaver.download()
expected_path = path_images / "manual"
expected_dirs = [ "3013000" ]
dirs = [f for f in expected_path.iterdir() if f.is_dir()]
assert set([d.name for d in dirs]) == set(expected_dirs)
for d in dirs:
expected_files = ["0.png", "1.png"]
files = [f.name for f in d.iterdir() if f.is_file()]
assert set(files) == set(expected_files)