Fix: send validated quiz data through websocket instead of raw data#6
Merged
Fix: send validated quiz data through websocket instead of raw data#6
Conversation
- Changed Quiz() validation to store the result in validated_quiz variable - Changed send_receive_messages() to send model_dump() of validated_quiz - This ensures numeric answers are converted to strings before sending to server - Fixes issue #2
- Added pytest as dev dependency in pyproject.toml - Created tests package with proper module documentation (__init__.py) - Added TestQuizValidation class in tests/test_main.py - Added test_numeric_answers_are_converted_to_strings() test case Test implementation: - Verifies that numeric answers from YAML are validated by Quiz model - Confirms that model_dump() converts integer answers to strings - Ensures websocket receives properly formatted data with string types Implementation notes: - Fixed main() function to store validated_quiz object - Changed send_receive_messages() to send validated_quiz.model_dump() - This change pairs with quiz-common PR #2 for full functionality Known limitation: - Test cannot currently run locally as quiz-common PR #2 is not yet merged - Once both PRs are merged, test will pass: uv run pytest tests/test_main.py -v - Setup for local testing to be documented during project sync meeting Related to issue #2
- Changed main() to store validated quiz in validated_quiz variable - Changed send_receive_messages() to accept validated Quiz object - Ensures numeric answers are converted to strings before sending to server - Removed pytest dependency from main project dependencies - This pairs with quiz-common PR #2 for full functionality Changes: - src/quiz_admin/__main__.py: Updated to use validated_quiz - pyproject.toml: Removed pytest Note: This fix requires quiz-common PR #2 to be merged for complete integration. Numeric answer conversion happens in quiz-common Option model via field validator.
ZelenyMartin
approved these changes
Apr 9, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Uh oh!
There was an error while loading. Please reload this page.