Compare commits

..

3 commits

Author SHA1 Message Date
116c21456f Minor fixes to testing whether a demo exists.
Add a unit test to validate functionality of this tricky corner of code.
2026-01-19 13:05:29 -05:00
2809f00191 Minor tweak to license specification. 2026-01-19 13:03:52 -05:00
54887efd02 Minor fix for loading map names from config. 2026-01-19 13:02:30 -05:00
4 changed files with 34 additions and 4 deletions

View file

@ -132,8 +132,10 @@ class WadMap(Wad):
]
if len(candidates) == 0:
raise Exception(
"no suitable demo candidates for WAD {} MAP {} name {}.".format(
self.wad, self.map, self.name_string
"no suitable demo candidates for WAD {} MAP {}{}.".format(
self.wad,
self.map,
f" name {self._name}" if self._name else "",
)
)
if len(candidates) == 1:

View file

@ -86,7 +86,7 @@ class Text(doomcc.doom_base.WadMap):
map_names = self._config.get("map_names")
if map_names is not None:
text = map_names.get(f"map{mapnum}")
if text != "":
if text is not None:
return text
return input("Map Name? ")

View file

@ -5,7 +5,7 @@ description = "Doom Command Center"
authors = [
{name = "yrriban",email = "yrriban@gmail.com"}
]
license = {text = "MIT"}
license = "MIT"
readme = "README.md"
requires-python = ">=3.12"
dependencies = [

28
tests/doom_base_test.py Normal file
View file

@ -0,0 +1,28 @@
import doomcc.doom_base
import os
import pathlib
import pytest
import tempfile
class Workbench:
pass
def test_demo_in_path():
w = Workbench()
w.demo_in_path = lambda: doomcc.doom_base.WadMap.demo_in_path(w)
w._file_base = lambda path: doomcc.doom_base.WadMap._file_base(w, path)
w.wad = pathlib.Path("scythe")
w.map = "01"
w.name_string = "_index"
w._name = "index"
with tempfile.TemporaryDirectory() as td:
w.demos = pathlib.Path(td)
with pytest.raises(Exception):
w.demo_in_path()
dp = pathlib.Path(td).joinpath("scythe")
os.mkdir(dp)
dp.joinpath("scythe_map01_index.lmp").touch()
assert w.demo_in_path() == dp.joinpath("scythe_map01_index.lmp")
dp.joinpath("scythe_map01_index-00028.lmp").touch()
assert w.demo_in_path() == dp.joinpath("scythe_map01_index-00028.lmp")