- `stone-furnace` 배치 후 자동으로 `coal`과 `iron-ore`/`copper-ore`를 투입하여 제련이 시작되도록 보정하는 기능 추가 - `insert_to_entity` 호출 전에 `can_insert` 여부를 확인하여 아이템 증발 위험을 줄이는 로직 개선 - `README.md`에 새로운 기능 설명 추가 - `tests/test_furnace_bootstrap.py` 및 `tests/test_insert_to_entity.py`에 대한 단위 테스트 추가
32 lines
1012 B
Python
32 lines
1012 B
Python
import unittest
|
|
|
|
from action_executor import ActionExecutor
|
|
|
|
|
|
class _CapturingRCON:
|
|
def __init__(self):
|
|
self.last_lua: str | None = None
|
|
|
|
def lua(self, code: str) -> str:
|
|
self.last_lua = code
|
|
# insert_to_entity는 Lua에서 "OK"/"NOT_FOUND"를 기대
|
|
return "OK"
|
|
|
|
|
|
class TestInsertToEntity(unittest.TestCase):
|
|
def test_insert_to_entity_checks_burner_can_insert(self):
|
|
"""
|
|
stone-furnace 같은 burner 엔티티에 대해,
|
|
burner.inventory에 넣기 전에 can_insert 여부를 확인해야 한다.
|
|
(fuel이 아닌 ore를 burner에 넣으려다 소비/미삽입 이슈 방지)
|
|
"""
|
|
rcon = _CapturingRCON()
|
|
ex = ActionExecutor(rcon) # type: ignore[arg-type]
|
|
|
|
ex.insert_to_entity(x=0, y=0, item="iron-ore", count=10)
|
|
|
|
assert rcon.last_lua is not None
|
|
# burner inventory branch에서 can_insert을 검사하도록 수정되어야 한다.
|
|
self.assertIn("fi.can_insert", rcon.last_lua)
|
|
|