From a2c008fc8716aaf98962c461b286d524bdb5417e Mon Sep 17 00:00:00 2001 From: snake-biscuits <36507175+snake-biscuits@users.noreply.github.com> Date: Tue, 3 Sep 2024 04:04:37 +0100 Subject: [PATCH] (tests.archives)(#194) Adding `infinity_ward.Iwd` tests --- tests/archives/infinity_ward/__init__.py | 0 tests/archives/infinity_ward/test_Iwd.py | 28 ++++++++++++++++++++++++ 2 files changed, 28 insertions(+) create mode 100644 tests/archives/infinity_ward/__init__.py create mode 100644 tests/archives/infinity_ward/test_Iwd.py diff --git a/tests/archives/infinity_ward/__init__.py b/tests/archives/infinity_ward/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/tests/archives/infinity_ward/test_Iwd.py b/tests/archives/infinity_ward/test_Iwd.py new file mode 100644 index 00000000..9529680e --- /dev/null +++ b/tests/archives/infinity_ward/test_Iwd.py @@ -0,0 +1,28 @@ +import pytest + +from bsp_tool.archives import infinity_ward + +from ... import files + + +iwd_dirs: files.LibraryGames +iwd_dirs = { + "Steam": { + "Call of Duty 2": ["Call of Duty 2/main/"]}} + + +library = files.game_library() +iwds = { + f"{section} | {game} | {short_path}": full_path + for section, game, paths in library.scan(iwd_dirs, "*.iwd") + for short_path, full_path in paths} + + +@pytest.mark.parametrize("filename", iwds.values(), ids=iwds.keys()) +def test_from_file(filename: str): + iwd = infinity_ward.Iwd.from_file(filename) + namelist = iwd.namelist() + assert isinstance(namelist, list), ".namelist() failed" + if len(namelist) != 0: + first_file = iwd.read(namelist[0]) + assert isinstance(first_file, bytes), ".read() failed"