Issue #8 — No unit tests for typeclasses or commands - Add pytest configuration via pyproject.toml - Add conftest.py with Evennia mocking fixtures - Add tests/typeclasses/test_audited_character.py — full AuditedCharacter test coverage - Add tests/typeclasses/test_rooms_exits.py — structural Room/Exit/Object tests - Add tests/commands/test_commands.py — all 8 command classes (Examine, Rooms, Status, Map, Academy, Smell, Listen, Who) - Tests cover: attribute init, rate-limited audit logging, movement tracking, command counting, session tracking, summarize, rotation, command metadata - Tests use mock-based approach so they run standalone without live Evennia Smallest concrete fix: new dedicated test directory with logical grouping. Tests verify critical audit behaviors, command output paths, and typeclass inheritance.
70 lines
1.7 KiB
Python
70 lines
1.7 KiB
Python
"""
|
|
pytest configuration and shared fixtures for Timmy Academy tests.
|
|
|
|
Uses Evennia test framework to run without full server.
|
|
"""
|
|
|
|
from __future__ import annotations
|
|
|
|
import pytest
|
|
from unittest.mock import MagicMock, PropertyMock
|
|
|
|
|
|
# Evennia test framework handles Django setup automatically.
|
|
# Import Evennia's test base to configure environment
|
|
try:
|
|
from evennia.utils.test_resources import EvenniaTest as BaseEvenniaTest
|
|
EVENNIA_AVAILABLE = True
|
|
except ImportError:
|
|
EVENNIA_AVAILABLE = False
|
|
BaseEvenniaTest = object # fallback stub
|
|
|
|
|
|
# ---------------------------------------------------------------------------
|
|
# Fixtures
|
|
# ---------------------------------------------------------------------------
|
|
|
|
@pytest.fixture(scope='session')
|
|
def evennia_test():
|
|
"""Return the Evennia test base class if available."""
|
|
return BaseEvenniaTest
|
|
|
|
|
|
@pytest.fixture
|
|
def mock_caller():
|
|
"""Create a mock caller (character) for command tests."""
|
|
caller = MagicMock()
|
|
caller.key = 'TestPlayer'
|
|
caller.location = MagicMock()
|
|
caller.location.key = 'TestRoom'
|
|
caller.location.db = {}
|
|
caller.msg = MagicMock()
|
|
caller.db = {}
|
|
return caller
|
|
|
|
|
|
@pytest.fixture
|
|
def mock_room():
|
|
"""Create a mock room with atmosphere."""
|
|
room = MagicMock()
|
|
room.key = 'Academy Hall'
|
|
room.db = {
|
|
'desc': 'A grand hall for learning.',
|
|
'atmosphere': {
|
|
'smells': 'Old books and ozone.',
|
|
'sounds': 'Soft humming of servers.',
|
|
'mood': 'focused'
|
|
},
|
|
'wing': 'hub'
|
|
}
|
|
return room
|
|
|
|
|
|
@pytest.fixture
|
|
def mock_account():
|
|
"""Mock connected account."""
|
|
acc = MagicMock()
|
|
acc.db_key = 'TestAccount'
|
|
acc.db_is_connected = True
|
|
return acc
|