Skip to content

test: add unit tests for gcode/history.py (fixes #66) - #77

Merged
shauryagangrade merged 2 commits into
shauryagangrade:mainfrom
HeaTTap:test/history-unit-tests
Aug 14, 2026
Merged

test: add unit tests for gcode/history.py (fixes #66)#77
shauryagangrade merged 2 commits into
shauryagangrade:mainfrom
HeaTTap:test/history-unit-tests

Conversation

@HeaTTap

@HeaTTap HeaTTap commented Aug 14, 2026

Copy link
Copy Markdown
Contributor

Fixes #66

Description

Adds a comprehensive unit test suite in tests/test_history.py for gcode/history.py, covering persistence operations, path sanitization, and error handling.

Key Test Cases Included

  • test_path_sanitization: Verifies session name sanitization replacing unsafe characters.
  • test_save_and_load_round_trip: Verifies saving and reloading LangChain message instances (SystemMessage, HumanMessage, AIMessage).
  • test_save_and_load_tool_call_round_trip: Verifies tool-call → ToolMessage pairing survives a save/load round-trip.
  • test_save_and_load_default_session: Verifies default session loading and saving.
  • test_load_missing_file: Verifies returning None when no session file exists.
  • test_load_corrupt_json & test_load_invalid_message_dict: Verifies returning None gracefully on malformed JSON or invalid schema.
  • test_clear_session & test_clear_default_session: Verifies deleting session files and safe no-op on missing files.
  • test_save_write_failure_resilience: Verifies handling disk write failures gracefully without raising exceptions.

Verification

  • 10 tests in tests/test_history.py pass — 100% coverage on gcode/history.py.
  • Full suite: 64 tests pass.
  • ruff check and ruff format --check clean.

@shauryagangrade
shauryagangrade merged commit 46cdab3 into shauryagangrade:main Aug 14, 2026
@shauryagangrade

Copy link
Copy Markdown
Owner

Merged. Thanks for your work here.

Give this repo a ⭐ so that we can reach more contributors like you :-)

If you would like to contribute to more repos just like this, I recommend:

https://github.com/shauryagangrade/intent-drift-skill
https://github.com/shauryagangrade/scout-issue
https://github.com/StudentSuite/StudyMap
https://github.com/shauryagangrade/GCode
https://github.com/shauryagangrade/intent-drift

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Testing]: Unit tests for gcode/history.py

2 participants