test: add test for message #2664
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Add comprehensive test coverage for message module
Summary
This PR adds comprehensive unit test coverage for the
chainlit.messagemodule, which previously had no test coverage. The test suite includes 34 test cases covering all message classes and their core functionality.What's Changed
backend/tests/test_message.py- Complete test suite for the message moduleTest Coverage
Test Classes
TestMessageBase (7 tests)
to_dict,from_dict)TestMessage (9 tests)
TestErrorMessage (4 tests)
TestAskUserMessage (4 tests)
TestAskFileMessage (4 tests)
TestAskActionMessage (3 tests)
TestMessageIntegration (2 tests)
Testing
All tests follow the existing project patterns:
pytestwithpytest-asynciofor async testsconftest.py(mock_chainlit_context, etc.)Expected Results
All 34 tests should pass, providing comprehensive coverage of the message module functionality.
Checklist
Related
This addresses the lack of test coverage for the
chainlit.messagemodule, which is a core component of the Chainlit framework for handling user and assistant messages.Contribution by Gittensor, learn more at https://gittensor.io/
Summary by cubic
Added comprehensive unit tests for the message module to verify serialization, streaming, send/update/remove, user/file/action/element prompts, and error handling. This strengthens reliability of core messaging flows and prevents regressions.
Written for commit 3a4ba01. Summary will update automatically on new commits.