67 lines
2.3 KiB
Python
67 lines
2.3 KiB
Python
"""Test that install.bat references files that actually exist in the repo.
|
|
|
|
Catches: deleted dependency files, renamed requirements, missing environment.yml.
|
|
"""
|
|
|
|
import os
|
|
|
|
ROOT = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
|
|
|
# Files install.bat references by name (not env vars or paths)
|
|
REQUIRED_FILES = [
|
|
"requirements.txt",
|
|
"requirements-win10.txt",
|
|
"requirements-win11.txt",
|
|
"environment.yml",
|
|
"environment-win10.yml",
|
|
"environment-win11.yml",
|
|
"find_python.bat",
|
|
]
|
|
|
|
# Files that may or may not exist depending on the branch
|
|
OPTIONAL_FILES = [
|
|
"dependencies/tesseract52.dll",
|
|
"dependencies/tesserocr.cp310-win_amd64.pyd",
|
|
"dependencies/tesserocr-2.5.2-cp310-cp310-win_amd64.whl",
|
|
]
|
|
|
|
|
|
def _exists(name):
|
|
return os.path.isfile(os.path.join(ROOT, name))
|
|
|
|
|
|
class TestInstallBatReferences:
|
|
def test_required_files_exist(self):
|
|
missing = [f for f in REQUIRED_FILES if not _exists(f)]
|
|
assert not missing, f"install.bat references missing files: {missing}"
|
|
|
|
def test_optional_files_at_least_one_exists(self):
|
|
existing = [f for f in OPTIONAL_FILES if _exists(f)]
|
|
assert len(existing) >= 1, (
|
|
"install.bat references tesseract/tesserocr dependencies but none exist in "
|
|
"dependencies/ directory — install.bat will silently skip OCR setup"
|
|
)
|
|
|
|
def test_install_bat_exists(self):
|
|
assert _exists("install.bat"), "install.bat is missing from repo root"
|
|
|
|
def test_run_botty_bat_exists(self):
|
|
assert _exists("run_botty.bat"), "run_botty.bat is missing from repo root"
|
|
|
|
def test_config_params_exists(self):
|
|
assert _exists("config/params.ini"), "config/params.ini is missing"
|
|
|
|
def test_config_game_ini_exists(self):
|
|
assert _exists("config/game.ini"), "config/game.ini is missing"
|
|
|
|
def test_tessdata_directory_exists(self):
|
|
tessdata = os.path.join(ROOT, "assets", "tessdata")
|
|
assert os.path.isdir(tessdata), "assets/tessdata/ directory is missing"
|
|
|
|
def test_tessdata_has_traineddata(self):
|
|
tessdata = os.path.join(ROOT, "assets", "tessdata")
|
|
trained = [f for f in os.listdir(tessdata) if f.endswith(".traineddata")]
|
|
assert len(trained) >= 1, "assets/tessdata/ has no .traineddata files"
|
|
|
|
def test_src_main_exists(self):
|
|
assert _exists("src/main.py"), "src/main.py is missing" |