Test files and initial data gathering completed
|
After Width: | Height: | Size: 768 KiB |
|
After Width: | Height: | Size: 2.5 MiB |
|
After Width: | Height: | Size: 2.5 MiB |
|
After Width: | Height: | Size: 2.5 MiB |
|
After Width: | Height: | Size: 2.5 MiB |
|
After Width: | Height: | Size: 2.5 MiB |
|
After Width: | Height: | Size: 2.5 MiB |
|
After Width: | Height: | Size: 2.5 MiB |
|
After Width: | Height: | Size: 2.5 MiB |
|
After Width: | Height: | Size: 2.5 MiB |
|
After Width: | Height: | Size: 2.5 MiB |
|
After Width: | Height: | Size: 2.5 MiB |
|
After Width: | Height: | Size: 2.5 MiB |
|
After Width: | Height: | Size: 2.5 MiB |
|
After Width: | Height: | Size: 2.5 MiB |
@@ -0,0 +1,70 @@
|
||||
import shutil
|
||||
from pathlib import Path
|
||||
|
||||
import pytest
|
||||
|
||||
import analyze
|
||||
|
||||
ALL_IMAGES = (
|
||||
sorted(Path("tests/images/harvesting").glob("*.png"))
|
||||
+ sorted(Path("tests/images/not_harvesting").glob("*.png"))
|
||||
)
|
||||
|
||||
assert len(ALL_IMAGES) > 0, "no images found under tests/images"
|
||||
|
||||
# Inventory capacity was observed to change as the player collects items.
|
||||
# Frames not listed here are expected to read 106.
|
||||
INVENTORY_EXPECTED = {
|
||||
"frame_00000.png": 110,
|
||||
"frame_00001.png": 110,
|
||||
"frame_00002.png": 108,
|
||||
"frame_00003.png": 108,
|
||||
}
|
||||
|
||||
OCR_AVAILABLE = analyze.pytesseract is not None and shutil.which("tesseract") is not None
|
||||
|
||||
pytestmark = pytest.mark.skipif(
|
||||
not OCR_AVAILABLE,
|
||||
reason="pytesseract or tesseract-ocr not installed",
|
||||
)
|
||||
|
||||
|
||||
@pytest.fixture(scope="session")
|
||||
def bar_values():
|
||||
values = {}
|
||||
for path in ALL_IMAGES:
|
||||
image = analyze.load_image(path)
|
||||
assert image is not None, f"cannot load {path}"
|
||||
values[path.name] = analyze.read_bar_values(image)
|
||||
return values
|
||||
|
||||
|
||||
def test_mana_is_32(bar_values):
|
||||
for name, values in bar_values.items():
|
||||
assert values["mana"] == 32, name
|
||||
|
||||
|
||||
def test_food_is_39(bar_values):
|
||||
for name, values in bar_values.items():
|
||||
assert values["food"] == 39, name
|
||||
|
||||
|
||||
def test_health_is_40(bar_values):
|
||||
for name, values in bar_values.items():
|
||||
assert values["health"] == 40, name
|
||||
|
||||
|
||||
def test_action_points_are_140(bar_values):
|
||||
for name, values in bar_values.items():
|
||||
assert values["action_points"] == 140, name
|
||||
|
||||
|
||||
def test_inventory_matches_expected(bar_values):
|
||||
for name, values in bar_values.items():
|
||||
expected = INVENTORY_EXPECTED.get(name, 106)
|
||||
assert values["inventory"] == expected, name
|
||||
|
||||
|
||||
def test_every_bar_has_a_value(bar_values):
|
||||
for name, values in bar_values.items():
|
||||
assert all(v is not None for v in values.values()), name
|
||||
@@ -0,0 +1,10 @@
|
||||
from pathlib import Path
|
||||
|
||||
import analyze
|
||||
|
||||
CORRUPT = sorted(Path("tests/images/corrupt").glob("*.png"))
|
||||
|
||||
|
||||
def test_corrupt_images_are_skipped_gracefully():
|
||||
for path in CORRUPT:
|
||||
assert analyze.load_image(path) is None, path
|
||||
@@ -0,0 +1,23 @@
|
||||
from pathlib import Path
|
||||
|
||||
import analyze
|
||||
|
||||
HARVESTING = sorted(Path("tests/images/harvesting").glob("*.png"))
|
||||
NOT_HARVESTING = sorted(Path("tests/images/not_harvesting").glob("*.png"))
|
||||
|
||||
assert len(HARVESTING) > 0, "no images found in tests/images/harvesting"
|
||||
assert len(NOT_HARVESTING) > 0, "no images found in tests/images/not_harvesting"
|
||||
|
||||
|
||||
def test_harvesting_frames_report_harvesting():
|
||||
for path in HARVESTING:
|
||||
image = analyze.load_image(path)
|
||||
assert image is not None, f"cannot load {path}"
|
||||
assert analyze.is_harvesting(image)["is_harvesting"] is True, path
|
||||
|
||||
|
||||
def test_not_harvesting_frames_report_not_harvesting():
|
||||
for path in NOT_HARVESTING:
|
||||
image = analyze.load_image(path)
|
||||
assert image is not None, f"cannot load {path}"
|
||||
assert analyze.is_harvesting(image)["is_harvesting"] is False, path
|
||||