mud/tests/test_player_caps.py
Jared Miller b0fcb080d3
Wire client capabilities into Player & terrain
Parse MTTS from telnetlib3 writer during connection and store capabilities
on Player.caps field. Add convenience property Player.color_depth that
delegates to caps.color_depth for easy access by rendering code.

Changes:
- Add caps field to Player with default 16-color ANSI capabilities
- Parse MTTS in server shell after Player creation using parse_mtts()
- Add Player.color_depth property for quick capability checks
- Add tests verifying Player caps integration and color_depth property
2026-02-07 22:44:45 -05:00

48 lines
1.7 KiB
Python

"""Tests for Player client capabilities integration."""
from mudlib.caps import ClientCaps
from mudlib.player import Player
def test_player_default_caps():
"""Player has default 16-color ANSI caps when created without explicit caps."""
player = Player(name="TestPlayer", x=0, y=0)
assert player.caps.ansi is True
assert player.caps.colors_256 is False
assert player.caps.truecolor is False
assert player.color_depth == "16"
def test_player_caps_truecolor():
"""Player with truecolor caps reports truecolor depth."""
caps = ClientCaps(ansi=True, utf8=True, colors_256=True, truecolor=True)
player = Player(name="TestPlayer", x=0, y=0, caps=caps)
assert player.color_depth == "truecolor"
def test_player_caps_256():
"""Player with 256-color caps reports 256 depth."""
caps = ClientCaps(ansi=True, utf8=True, colors_256=True, truecolor=False)
player = Player(name="TestPlayer", x=0, y=0, caps=caps)
assert player.color_depth == "256"
def test_player_caps_16():
"""Player with basic ANSI caps reports 16 depth."""
caps = ClientCaps(ansi=True, utf8=True)
player = Player(name="TestPlayer", x=0, y=0, caps=caps)
assert player.color_depth == "16"
def test_player_caps_property_delegates():
"""Player.color_depth delegates to caps.color_depth."""
player = Player(name="TestPlayer", x=0, y=0)
# Modify caps and verify color_depth reflects the change
player.caps = ClientCaps(ansi=True, colors_256=True, truecolor=True)
assert player.color_depth == "truecolor"
player.caps = ClientCaps(ansi=True, colors_256=True, truecolor=False)
assert player.color_depth == "256"
player.caps = ClientCaps(ansi=True)
assert player.color_depth == "16"