2025-12-01 02:42:10 -05:00
|
|
|
import cliff.app
|
|
|
|
|
import dcc.play
|
|
|
|
|
import logging
|
2025-12-24 18:09:49 -05:00
|
|
|
import os
|
2025-12-01 02:42:10 -05:00
|
|
|
import mockito.matchers
|
|
|
|
|
import pathlib
|
|
|
|
|
import tempfile
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
logger = logging.getLogger(__name__)
|
|
|
|
|
|
|
|
|
|
|
2025-12-24 18:09:49 -05:00
|
|
|
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 18:09:49 -05:00
|
|
|
dcc.play.Play.__init__ = lambda self: None
|
|
|
|
|
dcc.play.Play.get_epilog = lambda self: ""
|
|
|
|
|
rig = dcc.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)
|
|
|
|
|
):
|
2025-12-24 18:09:49 -05:00
|
|
|
assert rig.run(parsed_args) is None
|