Add a test for the play command.
This commit is contained in:
parent
57fa261f90
commit
47133bdff7
1 changed files with 52 additions and 0 deletions
52
tests/play_test.py
Normal file
52
tests/play_test.py
Normal file
|
|
@ -0,0 +1,52 @@
|
||||||
|
import cliff.app
|
||||||
|
import dcc.play
|
||||||
|
import logging
|
||||||
|
import mockito.matchers
|
||||||
|
import pathlib
|
||||||
|
import subprocess
|
||||||
|
import tempfile
|
||||||
|
|
||||||
|
|
||||||
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
|
def test_play(when):
|
||||||
|
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()
|
||||||
|
zero = subprocess.CompletedProcess
|
||||||
|
zero.returncode = 0
|
||||||
|
when(subprocess).run(
|
||||||
|
[
|
||||||
|
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(zero)
|
||||||
|
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"])
|
||||||
|
assert rig.run(parsed_args) == 0
|
||||||
Loading…
Add table
Add a link
Reference in a new issue