import asyncio import json import zipfile import pytest from app.import_library import main @pytest.mark.parametrize("archived", [False, True]) def test_single_checks_distribution_without_treating_contents_as_games(tmp_path, archived): source = tmp_path / "One" (source / "game").mkdir(parents=True) (source / "game/script.rpy").write_text('label start:\n "Hello"\n return\n') if archived: archive = tmp_path / "One.zip" with zipfile.ZipFile(archive, "w") as handle: handle.write(source / "game/script.rpy", "One/game/script.rpy") source = archive output = tmp_path / "report.json" asyncio.run(main([str(source), "--single", "--check", "--output", str(output)])) results = json.loads(output.read_text(encoding="utf-8")) assert len(results) == 1 assert results[0]["game"] == source.name assert results[0]["compatible"] is True assert "versionId" not in results[0] def test_single_rejection_writes_report_and_returns_failure(tmp_path): source = tmp_path / "game" source.mkdir() (source / "script.rpy").write_text("label start:\n jump missing\n") output = tmp_path / "report.json" with pytest.raises(SystemExit) as error: asyncio.run(main([str(source), "--single", "--check", "--output", str(output)])) assert error.value.code == 2 assert json.loads(output.read_text(encoding="utf-8"))[0]["compatible"] is False