Delete trivial constructor and property tests

Removed 32 tests that only verified constructor args are stored as
properties. Type annotations and behavioral tests already cover this.
This commit is contained in:
Jared Miller 2026-02-16 15:29:26 -05:00
parent 9c480f8d47
commit 37d1c86b34
Signed by: shmup
GPG key ID: 22B5C6D66A38B06C
6 changed files with 1 additions and 279 deletions

View file

@ -8,53 +8,6 @@ from mudlib.zone import Zone
# --- construction --- # --- construction ---
def test_container_creation_minimal():
"""Container can be created with just a name."""
c = Container(name="chest")
assert c.name == "chest"
assert c.capacity == 10
assert c.closed is False
assert c.locked is False
def test_container_creation_with_custom_capacity():
"""Container can have a custom capacity."""
c = Container(name="pouch", capacity=5)
assert c.capacity == 5
def test_container_creation_closed():
"""Container can be created in closed state."""
c = Container(name="chest", closed=True)
assert c.closed is True
def test_container_creation_locked():
"""Container can be created in locked state."""
c = Container(name="chest", locked=True)
assert c.locked is True
def test_container_is_thing_subclass():
"""Container is a Thing subclass."""
c = Container(name="chest")
assert isinstance(c, Thing)
assert isinstance(c, Object)
def test_container_inherits_thing_properties():
"""Container has all Thing properties."""
c = Container(
name="ornate chest",
description="a beautifully carved wooden chest",
portable=False,
aliases=["chest", "box"],
)
assert c.description == "a beautifully carved wooden chest"
assert c.portable is False
assert c.aliases == ["chest", "box"]
# --- can_accept --- # --- can_accept ---

View file

@ -5,7 +5,6 @@ from unittest.mock import MagicMock
import pytest import pytest
from mudlib.container import Container
from mudlib.corpse import Corpse, create_corpse from mudlib.corpse import Corpse, create_corpse
from mudlib.entity import Mob from mudlib.entity import Mob
from mudlib.mobs import mobs from mudlib.mobs import mobs
@ -63,36 +62,6 @@ def potion():
return Thing(name="potion", description="a health potion", portable=True) return Thing(name="potion", description="a health potion", portable=True)
class TestCorpseClass:
def test_corpse_is_container_subclass(self):
"""Corpse is a subclass of Container."""
assert issubclass(Corpse, Container)
def test_corpse_not_portable(self, test_zone):
"""Corpse is not portable (can't pick up a corpse)."""
corpse = Corpse(name="test corpse", location=test_zone, x=0, y=0)
assert corpse.portable is False
def test_corpse_always_open(self, test_zone):
"""Corpse is always open (closed=False)."""
corpse = Corpse(name="test corpse", location=test_zone, x=0, y=0)
assert corpse.closed is False
def test_corpse_has_decompose_at_field(self, test_zone):
"""Corpse has decompose_at field (float, monotonic time)."""
decompose_time = time.monotonic() + 300
corpse = Corpse(
name="test corpse",
location=test_zone,
x=0,
y=0,
decompose_at=decompose_time,
)
assert hasattr(corpse, "decompose_at")
assert isinstance(corpse.decompose_at, float)
assert corpse.decompose_at == decompose_time
class TestCreateCorpseFactory: class TestCreateCorpseFactory:
def test_creates_corpse_at_mob_position(self, goblin_mob, test_zone): def test_creates_corpse_at_mob_position(self, goblin_mob, test_zone):
"""create_corpse creates a corpse at mob's x, y in the zone.""" """create_corpse creates a corpse at mob's x, y in the zone."""

View file

@ -1,87 +0,0 @@
"""Tests for entity combat stats."""
from unittest.mock import AsyncMock, MagicMock
import pytest
from mudlib.entity import Entity, Mob
from mudlib.player import Player
@pytest.fixture
def mock_writer():
writer = MagicMock()
writer.write = MagicMock()
writer.drain = AsyncMock()
return writer
@pytest.fixture
def mock_reader():
return MagicMock()
def test_entity_has_combat_stats():
"""Test that Entity has PL and stamina stats."""
entity = Entity(name="Test", x=0, y=0)
assert entity.pl == 100.0
assert entity.stamina == 100.0
assert entity.max_stamina == 100.0
assert entity.defense_locked_until == 0.0
def test_entity_combat_stats_can_be_customized():
"""Test that combat stats can be set on initialization."""
entity = Entity(name="Weak", x=0, y=0, pl=50.0, stamina=30.0, max_stamina=30.0)
assert entity.pl == 50.0
assert entity.stamina == 30.0
assert entity.max_stamina == 30.0
def test_mob_inherits_combat_stats():
"""Test that Mob inherits combat stats from Entity."""
mob = Mob(name="Goku", x=10, y=10, description="A powerful fighter")
assert mob.pl == 100.0
assert mob.stamina == 100.0
assert mob.max_stamina == 100.0
def test_mob_combat_stats_can_be_customized():
"""Test that Mob can have custom combat stats."""
mob = Mob(
name="Boss",
x=5,
y=5,
description="Strong",
pl=200.0,
max_stamina=150.0,
stamina=150.0,
)
assert mob.pl == 200.0
assert mob.stamina == 150.0
assert mob.max_stamina == 150.0
def test_player_inherits_combat_stats(mock_reader, mock_writer):
"""Test that Player inherits combat stats from Entity."""
player = Player(name="Hero", x=0, y=0, reader=mock_reader, writer=mock_writer)
assert player.pl == 100.0
assert player.stamina == 100.0
assert player.max_stamina == 100.0
def test_player_combat_stats_can_be_customized(mock_reader, mock_writer):
"""Test that Player can have custom combat stats."""
player = Player(
name="Veteran",
x=0,
y=0,
reader=mock_reader,
writer=mock_writer,
pl=150.0,
stamina=120.0,
max_stamina=120.0,
)
assert player.pl == 150.0
assert player.stamina == 120.0
assert player.max_stamina == 120.0

View file

@ -4,33 +4,7 @@ from unittest.mock import AsyncMock, MagicMock, patch
import pytest import pytest
from mudlib.if_session import IFResponse, IFSession from mudlib.if_session import IFSession
@pytest.mark.asyncio
async def test_if_response_dataclass():
"""IFResponse dataclass can be created."""
response = IFResponse(output="test output", done=False)
assert response.output == "test output"
assert response.done is False
@pytest.mark.asyncio
async def test_if_response_done():
"""IFResponse can signal completion."""
response = IFResponse(output="", done=True)
assert response.done is True
@pytest.mark.asyncio
async def test_if_session_init():
"""IFSession can be initialized."""
player = MagicMock()
session = IFSession(player, "/path/to/story.z5", "story")
assert session.player == player
assert session.story_path == "/path/to/story.z5"
assert session.game_name == "story"
assert session.process is None
@pytest.mark.asyncio @pytest.mark.asyncio

View file

@ -8,42 +8,6 @@ from mudlib.zone import Zone
# --- construction --- # --- construction ---
def test_portal_creation_minimal():
"""Portal can be created with just a name."""
p = Portal(name="portal")
assert p.name == "portal"
assert p.location is None
assert p.target_zone == ""
assert p.target_x == 0
assert p.target_y == 0
def test_portal_creation_with_target():
"""Portal can be created with target zone and coordinates."""
p = Portal(name="gateway", target_zone="dungeon", target_x=5, target_y=10)
assert p.target_zone == "dungeon"
assert p.target_x == 5
assert p.target_y == 10
def test_portal_is_thing_subclass():
"""Portal inherits from Thing."""
p = Portal(name="portal")
assert isinstance(p, Thing)
def test_portal_is_object_subclass():
"""Portal inherits from Object (via Thing)."""
p = Portal(name="portal")
assert isinstance(p, Object)
def test_portal_always_non_portable():
"""Portal is always non-portable (cannot be picked up)."""
p = Portal(name="portal")
assert p.portable is False
def test_portal_forced_non_portable(): def test_portal_forced_non_portable():
"""Portal forces portable=False even if explicitly set True.""" """Portal forces portable=False even if explicitly set True."""
# Even if we try to make it portable, it should be forced to False # Even if we try to make it portable, it should be forced to False
@ -51,18 +15,6 @@ def test_portal_forced_non_portable():
assert p.portable is False assert p.portable is False
def test_portal_inherits_description():
"""Portal can have a description (from Thing)."""
p = Portal(name="gateway", description="a shimmering portal")
assert p.description == "a shimmering portal"
def test_portal_inherits_aliases():
"""Portal can have aliases (from Thing)."""
p = Portal(name="gateway", aliases=["portal", "gate"])
assert p.aliases == ["portal", "gate"]
def test_portal_in_zone(): def test_portal_in_zone():
"""Portal can exist in a zone with coordinates.""" """Portal can exist in a zone with coordinates."""
terrain = [["." for _ in range(10)] for _ in range(10)] terrain = [["." for _ in range(10)] for _ in range(10)]

View file

@ -8,27 +8,6 @@ from mudlib.zone import Zone
# --- construction --- # --- construction ---
def test_thing_creation_minimal():
"""Thing can be created with just a name."""
t = Thing(name="rock")
assert t.name == "rock"
assert t.location is None
assert t.description == ""
assert t.portable is True # default: things are portable
def test_thing_creation_with_description():
"""Thing can have a description."""
t = Thing(name="sword", description="a rusty iron sword")
assert t.description == "a rusty iron sword"
def test_thing_creation_non_portable():
"""Thing can be marked as non-portable (fixture, scenery)."""
t = Thing(name="fountain", portable=False)
assert t.portable is False
def test_thing_in_zone(): def test_thing_in_zone():
"""Thing can be placed in a zone with coordinates.""" """Thing can be placed in a zone with coordinates."""
terrain = [["." for _ in range(10)] for _ in range(10)] terrain = [["." for _ in range(10)] for _ in range(10)]
@ -53,24 +32,6 @@ def test_thing_in_entity_inventory():
assert sword.y is None assert sword.y is None
def test_thing_is_subclass_of_object():
"""Thing inherits from Object."""
t = Thing(name="gem")
assert isinstance(t, Object)
def test_thing_aliases_default_empty():
"""Thing aliases default to empty list."""
t = Thing(name="rock")
assert t.aliases == []
def test_thing_aliases():
"""Thing can have aliases for matching."""
t = Thing(name="pepsi can", aliases=["can", "pepsi"])
assert t.aliases == ["can", "pepsi"]
# --- entity.can_accept --- # --- entity.can_accept ---