doomcc/tests/play_test.py

56 lines
1.6 KiB
Python
Raw Normal View History

2025-12-01 02:42:10 -05:00
import cliff.app
2025-12-24 23:01:25 -05:00
import doomcc.play
2025-12-01 02:42:10 -05:00
import logging
import os
2025-12-01 02:42:10 -05:00
import mockito.matchers
import pathlib
import tempfile
logger = logging.getLogger(__name__)
def test_play(expect):
2025-12-01 02:42:10 -05:00
with tempfile.TemporaryDirectory() as td:
tdp = pathlib.Path(td)
tdp.joinpath("config.toml").write_text(
"""
dsda = "dsda-doom/exe"
iwad = "DOOM2.WAD"
complevel = "2"
"""
)
pwp = tdp.joinpath("pwads")
pwp.mkdir()
scp = pwp.joinpath("scythe")
scp.mkdir()
scp.joinpath("config.toml").touch()
scp.joinpath("scythe.wad").touch()
2025-12-24 23:01:25 -05:00
doomcc.play.Play.__init__ = lambda self: None
doomcc.play.Play.get_epilog = lambda self: ""
rig = doomcc.play.Play()
rig._hooks = []
parser = rig.get_parser("test_play")
parsed_args = parser.parse_args(args=["--doom", td, "scythe", "01"])
2025-12-24 18:35:43 -05:00
with (
expect(os, times=1)
.execv(
2025-12-01 02:42:10 -05:00
tdp.joinpath("dsda-doom").joinpath("exe"),
2025-12-24 18:35:43 -05:00
[
tdp.joinpath("dsda-doom").joinpath("exe"),
"-iwad",
tdp.joinpath("iwads").joinpath("DOOM2.WAD"),
"-file",
tdp.joinpath("pwads").joinpath("scythe").joinpath("scythe.wad"),
"-complevel",
"2",
"-skill",
"4",
"-warp",
"01",
],
)
.thenReturn(None)
):
assert rig.run(parsed_args) is None