Skip to content

test(pykotor): area layout deserialize errors and object roundtrip#236

Draft
cursor[bot] wants to merge 1 commit into
masterfrom
cursor/regression-test-coverage-7c30
Draft

test(pykotor): area layout deserialize errors and object roundtrip#236
cursor[bot] wants to merge 1 commit into
masterfrom
cursor/regression-test-coverage-7c30

Conversation

@cursor
Copy link
Copy Markdown
Contributor

@cursor cursor Bot commented May 9, 2026

Description

Adds regression tests for recently merged headless area layout and JSON I/O: invalid saved data, impossible tile extension, and placed objects.

Type of Change

  • ✅ Test addition or update

Package(s) Affected

  • PyKotor (core library)

Risky behavior now covered

  • extend_tile_from_wall / _best_adjacent_wall_hook: When the target tile template has no wall hook matching the active wall’s template id, layout extension must fail with a clear ValueError instead of silently misplacing geometry.
  • area_layout_from_dict: Missing kitID in the kits map and invalid floor templateID overrides must raise predictable ValueErrors (bad hand-edited or merged layout JSON).
  • Objects in layout JSON: AreaRoom.add_object data must round-trip through area_layout_to_dict / area_layout_from_dict with kit id, template id, and position preserved.

Test files added/updated

  • Libraries/PyKotor/tests/test_area_layout.py — extended _layout_test_kit() with an OBJECT template for round-trip coverage; new tests for hook mismatch, missing kit, bad floor override, and object serialization.

Why these tests materially reduce regression risk

Indoor / module-design tooling depends on deterministic layout state and safe deserialization. Silent mis-linking of tiles or accepting corrupt JSON would corrupt walkmeshes and MDL placement downstream (area_layout_to_merged_bwm, area_layout_model_placements). These tests lock in explicit failure modes and prove the object list survives save/load, which was not previously asserted.

Testing

  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes

Test Results

cd Libraries/PyKotor && uv run pytest --import-mode=importlib -m "not gui and not slow" tests/test_area_layout.py -v
# 8 passed

Also: uv run ruff check tests/test_area_layout.py and uv run ruff format tests/test_area_layout.py.

Checklist

  • My code follows the project's style guidelines
  • I have performed a self-review of my own code
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes

Related Issues

Regression coverage automation (cron); no specific issue.

Additional Notes

Tests are fully deterministic (synthetic TileKit fixtures, no disk or network). uv sync at workspace root can fail on unpublished optional deps; tests were run from Libraries/PyKotor with uv sync --extra dev per package README patterns.

AgentDecompile status: Skipped - test-only change, no game-engine or binary behavior :(

Open in Web View Automation 

Co-authored-by: Boden <th3w1zard1@users.noreply.github.com>
@github-actions github-actions Bot added python Pull requests that update python code libraries size/M Medium PR (100-300 lines) labels May 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

libraries python Pull requests that update python code size/M Medium PR (100-300 lines)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant