Repository navigation
test: pure-logic unit tests for stdlib, core, backends, telemetry (#860) - #862
Merged
planetf1 merged 3 commits intoApr 15, 2026
Merged
Conversation
~280 new unit tests covering every remaining pure-logic gap in the library that doesn't require live backends, GPU, or optional infrastructure. Areas covered: - stdlib/components: SimpleComponent, Instruction, Message/ToolMessage/chat, GenerativeStub (pure helpers + _parse), Query/Transform/MObject - stdlib/functional: _parse_and_clean_image_args - stdlib/sampling: majority_voting compare_strings (math + RougeL), sofai static helpers, RepairTemplateStrategy.repair() - stdlib/session: backend_name_to_class, get_session error path - telemetry: backend_instrumentation helpers, tracing _set_attribute_safe, end_backend_span (in new test_tracing_helpers.py, not behind OTel guard) - backends: get_value/to_tool_calls/to_chat (utils), OpenAI filter/merge helpers, Ollama merge helpers + chat_response_delta_merge - formatters/granite/base: find_substring_in_text - core: CBlock TypeError, ImageBlock validation, MOT._copy_from, ValidationResult properties, default_output_to_bool Infrastructure: - require_nltk_data() predicate added to test/predicates.py — distinguishes "nltk not installed" from "punkt_tab not downloaded" in skip messages. Applied to the two tests (Granite 3.2/3.3 citation pipeline) that call nltk.sent_tokenize(). - test_tracing_helpers.py: split 9 mock-based tracing tests out of the OTel-gated test_tracing.py so they run unconditionally. Closes generative-computing#860. Part of generative-computing#813. Parent epic: generative-computing#726.
planetf1
force-pushed
the
test/coverage-gaps-813
branch
from
April 15, 2026 09:06
2dff0b7 to
9caaeb7
Compare
planetf1
marked this pull request as ready for review
April 15, 2026 09:20
jakelorocco
reviewed
Apr 15, 2026
- test_simplify_and_merge_none_returns_empty_dict: assert result == {}
rather than just isinstance check
- test_simplify_and_merge_per_call_overrides_backend: extract
_make_backend() helper so the override test can construct a backend
with a pre-set num_predict=128, proving the per-call value of 256
actually wins the merge
Address review feedback on mapping tests (ollama + openai): 1. Structural consistency — assert from_mellea keys are a subset of to_mellea values (maps agree with each other) 2. Iterative round-trip — exercise _simplify_and_merge and _make_backend_specific_and_remove against every map entry, verifying the methods actually use the maps correctly 3. Hardcoded anchor — one named test per backend for the most critical mapping (num_predict / max_completion_tokens ↔ MAX_NEW_TOKENS) to catch wrong-string regressions with a meaningful failure message For OpenAI, structural and round-trip tests are parametrized over chats/completions since it maintains separate map pairs. Also: extract _make_backend() helper in test_openai_unit.py (matching the ollama pattern) so the override test can construct a backend with pre-set model options.
jakelorocco
approved these changes
Apr 15, 2026
github-merge-queue
Bot
removed this pull request from the merge queue due to no response for status checks
Apr 15, 2026
Merged
via the queue into
generative-computing:main
with commit Apr 15, 2026
051066d
4 checks passed
akihikokuroda
pushed a commit
to akihikokuroda/mellea
that referenced
this pull request
May 27, 2026
…nerative-computing#860) (generative-computing#862) * test: add pure-logic unit tests for stdlib, core, backends, telemetry ~280 new unit tests covering every remaining pure-logic gap in the library that doesn't require live backends, GPU, or optional infrastructure. Areas covered: - stdlib/components: SimpleComponent, Instruction, Message/ToolMessage/chat, GenerativeStub (pure helpers + _parse), Query/Transform/MObject - stdlib/functional: _parse_and_clean_image_args - stdlib/sampling: majority_voting compare_strings (math + RougeL), sofai static helpers, RepairTemplateStrategy.repair() - stdlib/session: backend_name_to_class, get_session error path - telemetry: backend_instrumentation helpers, tracing _set_attribute_safe, end_backend_span (in new test_tracing_helpers.py, not behind OTel guard) - backends: get_value/to_tool_calls/to_chat (utils), OpenAI filter/merge helpers, Ollama merge helpers + chat_response_delta_merge - formatters/granite/base: find_substring_in_text - core: CBlock TypeError, ImageBlock validation, MOT._copy_from, ValidationResult properties, default_output_to_bool Infrastructure: - require_nltk_data() predicate added to test/predicates.py — distinguishes "nltk not installed" from "punkt_tab not downloaded" in skip messages. Applied to the two tests (Granite 3.2/3.3 citation pipeline) that call nltk.sent_tokenize(). - test_tracing_helpers.py: split 9 mock-based tracing tests out of the OTel-gated test_tracing.py so they run unconditionally. Closes generative-computing#860. Part of generative-computing#813. Parent epic: generative-computing#726. * test: strengthen ollama unit test assertions - test_simplify_and_merge_none_returns_empty_dict: assert result == {} rather than just isinstance check - test_simplify_and_merge_per_call_overrides_backend: extract _make_backend() helper so the override test can construct a backend with a pre-set num_predict=128, proving the per-call value of 256 actually wins the merge * test: replace hardcoded mapping spot-checks with three-layer strategy Address review feedback on mapping tests (ollama + openai): 1. Structural consistency — assert from_mellea keys are a subset of to_mellea values (maps agree with each other) 2. Iterative round-trip — exercise _simplify_and_merge and _make_backend_specific_and_remove against every map entry, verifying the methods actually use the maps correctly 3. Hardcoded anchor — one named test per backend for the most critical mapping (num_predict / max_completion_tokens ↔ MAX_NEW_TOKENS) to catch wrong-string regressions with a meaningful failure message For OpenAI, structural and round-trip tests are parametrized over chats/completions since it maintains separate map pairs. Also: extract _make_backend() helper in test_openai_unit.py (matching the ollama pattern) so the override test can construct a backend with pre-set model options.
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.
Misc PR
Type of PR
Description
Adds ~280 new unit tests covering the remaining pure-logic gaps in the library — everything that can be tested without a live backend, GPU, or optional infrastructure dependency. All tests run in the default
pytestinvocation with no backend markers needed.What's been added
stdlib/componentstest_simple,test_instruction,test_chat(extended),test_genstub_unit,test_mobjectstdlib/functionaltest_functional_unitstdlib/samplingtest_majority_voting_unit,test_sofai_unit,test_sampling_base_unitstdlib/sessiontest_session_unittelemetrytest_backend_instrumentation,test_tracing_helpersbackendstest_utils(extended),test_openai_unit,test_ollama_unitformatters/granite/basetest_base_utilcoretest_base(extended),test_requirement_helpersTwo small infrastructure additions worth calling out:
require_nltk_data()predicate added totest/predicates.py. The Granite 3.2/3.3 citation pipeline tests callnltk.sent_tokenize, which needs thepunkt_tabdata download. The predicate skips with an actionable message that distinguishes "package not installed" from "data not downloaded". CI already runspython -m nltk.downloader punkt_tabinquality.yml.test_tracing_helpers.py— the mock-based tracing helper tests have been split out of the OTel-gatedtest_tracing.pyinto a new file without a module-levelimportorskip, so they run unconditionally. The one test that genuinely needs OTel uses a per-testimportorskip.Coverage improvement (local filter, unit/integration only)
stdlib/components/backends/(all)core/Testing