Skip to content

Testing#7

Open
PDFour4 wants to merge 8 commits intof25from
testing
Open

Testing#7
PDFour4 wants to merge 8 commits intof25from
testing

Conversation

@PDFour4
Copy link
Copy Markdown

@PDFour4 PDFour4 commented Apr 3, 2026

Objective

This PR introduces a robust suite of unit tests to validate our LLM parsing logic and ensure the microservice safely handles the unpredictability of local AI models.

Changes Made

Expanded test_translator.py to cover the following scenarios:

  • Multi-Language Support: Verified successful extraction and translation formatting for various non-English languages.

  • LLM Output Quirks: Ensured the parser safely ignores conversational filler, handles out-of-order keys, and strips extra whitespace.

  • Formatting Preservation: Confirmed that colons, emojis, and HTML/Markdown tags within the translated text are perfectly preserved for the NodeBB frontend.

  • Fallback Mechanisms: Tested try/except blocks against critical failures, including missing JSON keys, empty responses, invalid boolean text (e.g., "Not Sure"), and raw API crashes.

How to Verify

Run the following command locally or in the Dev Container to verify all tests pass:

uv run pytest

Can also run the following for more details on the specific tests being run.

uv run pytest -vv

(All tests are currently passing locally with 100% success).

Copy link
Copy Markdown

@bendnema bendnema left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great coverage of the code, and good variation in what the model recieves

@pskodr pskodr self-requested a review April 3, 2026 20:58
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

graceful fallbacks are well tested, parsing edge cases are covered, and HTML preservation is good for NodeBB site preservation tests.

Copy link
Copy Markdown

@pskodr pskodr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good to merge

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.

4 participants