- Create tests/ package with Django/Evennia environment setup - Add test_audited_character.py: at_object_creation, at_post_move, at_pre_cmd, at_pre_puppet, at_post_unpuppet, prune_audit_history, get_audit_summary, and audit log rate limiting tests - Add test_commands.py: CmdExamine, CmdRooms, CmdStatus, CmdMap, CmdAcademy, CmdSmell, CmdListen, CmdWho (presence and attribute tests) - Add test_rebuild_world.py: parse_wing_file, ROOM_CONFIG consistency, WING_INFO metadata, bidirectional exit verification concept - Uses evennia.utils.test_resources for serverless testing
28 lines
874 B
Python
28 lines
874 B
Python
# -*- coding: utf-8 -*-
|
|
"""
|
|
Unit test package for Timmy Academy.
|
|
|
|
This module configures the Django/Evennia test environment when
|
|
pytest or the test runner loads the tests package.
|
|
"""
|
|
|
|
import os
|
|
import sys
|
|
from pathlib import Path
|
|
|
|
# Compute the game root (two levels up from this file)
|
|
TESTS_DIR = Path(__file__).parent.absolute()
|
|
GAME_DIR = TESTS_DIR.parent.absolute()
|
|
|
|
# Add game dir to sys.path so imports like `typeclasses.foo` work
|
|
if str(GAME_DIR) not in sys.path:
|
|
sys.path.insert(0, str(GAME_DIR))
|
|
|
|
# Configure Django settings for test run
|
|
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'server.conf.settings')
|
|
|
|
# Import Evennia test resources to enable typeclass/command testing
|
|
# without a running server. This must be done after settings are configured.
|
|
import evennia
|
|
import evennia.utils.test_resources # noqa: F401 — side effects: installs test hooks
|