test: optimize test suite — 364→250 tests, 83% coverage - #61
Merged
Conversation
added 17 commits
July 6, 2026 11:07
Deleted exact copies of test_integration.py and test_auth_backup.py: - test_all.py: duplicates test_core + test_features + test_mcp - test_mcp/test_mcp.py: exact copy of test_auth_backup.py - test_lifecycle/test_lifecycle.py: copies test_integration.py - test_hooks/test_hooks.py: copies test_integration.py - test_graph/test_graph.py: copies test_integration.py - test_rag/test_rag.py: copies test_integration.py - test_rag/test_rag_edge_cases.py: overlap with test_integration + search_facade
Kept: test_reflex_buffer (unique L1 buffer test), test_compression (unique feature) Removed: 5 core tests + 5 feature tests that duplicated test_integration.py
…0 tests) Removed: backup(4), audit(3), rate_limiter(2), import_export(1) All duplicated by test_integration.py
Kept: remember/recall/forget (parametrized user/agent), rag (4), saga, middleware, embeddings, migrations, connection_manager, dashboard, metrics. Removed: duplicate tests covered by test_tools_e2e.py and unit tests.
Merged test_memory_remember_user + test_memory_remember_agent into
single test_memory_remember with @pytest.mark.parametrize('layer', ['user', 'agent']).
Merged test_remember_user + test_remember_agent into single parametrized test.
Phase 1 (analysis) + Phase 2 (parametrize): - test_rag_scoring: 24→12 functions (weights, corpus_stats, relevance, novelty, type_boost) - test_rag_search_facade: 21→18 functions (auto_strategy 4→1) - test_memory_types: 16→10 functions (can_archive 5→2, kind_for_text 4→1) - test_importance_v2: 15→14 functions (technical_keywords ru/en→1) - test_mib_quantize: 11→10 functions (hamming_distance 2→1) - test_tools_unit: 15→14 functions (remember_user/agent→1) Test functions: 364→356 (-8 functions merged into parametrized)
Added 3 new test classes: - TestImportanceGateProperties: gate_always_returns_bool, non_matching_tool_passes - TestMemoryTypeProperties: instruction_never_decays, fact_always_decays, protected_kinds_never_archive, kind_for_text_returns_valid - TestPathSafetyProperties: resolve_stays_within_base Phase 3 of Plan-test.md: Property-Based Expansion.
Deleted: - test_apply_decay_instruction_never_decays (covered by test_instruction_never_decays) - test_can_archive_protected x3 (covered by test_protected_kinds_never_archive) - test_importance_gate_passes_non_matching_tool (covered by test_non_matching_tool_passes) - test_safe_resolve_within_base (covered by test_resolve_stays_within_base) - test_safe_resolve_traversal_raises (covered by test_resolve_stays_within_base) - test_safe_resolve_absolute_escape_raises (covered by test_resolve_stays_within_base)
Added 14 new property tests (25→39): - TestSagaProperties: saga_name_preserved, add_steps_count - TestEmbeddingProperties: hash_embedding_correct_dim, normalized, deterministic, similarity_self_is_one, similarity_symmetric - TestSecretsProperties: encrypt_decrypt_roundtrip_dict/list, different_ciphertext, min_blob_size - TestImportanceGateProperties: gate_always_returns_bool, non_matching_tool_passes - TestMemoryTypeProperties: instruction_never_decays, fact_always_decays, protected_kinds_never_archive, kind_for_text_returns_valid - TestPathSafetyProperties: resolve_stays_within_base Removed 12 redundant unit tests: - test_secrets: encrypt_decrypt_roundtrip, different_nonces_per_call (covered by property tests) - test_embeddings: hash_embedding_dim/normalized/deterministic, similarity_identical/symmetric - test_saga_unit: add_step, status_property, data_property, get_state
Added 6 property tests (39→45): - TestConnectionProperties: insert_fetchall_roundtrip, get_reuses_connection, execute_script_works - TestCacheProperties: set_get_roundtrip, get_missing_returns_none, size_after_inserts Removed 8 unit tests: - test_connection: get_creates_db, reuses, execute_and_fetch, executemany, executescript, execute_script, fetchall - test_shared: test_cache Total: 352 tests, all passing.
Removed 13 tests that only check values without testing behavior: - test_auth_backup: mcp_tools_count, mcp_tools_are_async, mcp_server_name, mcp_server_instructions, config_singleton, config_get, config_hooks - test_tools_unit: validate_layer_valid, validate_layer_invalid, get_cache_key - test_migrations_coverage: get_current_version_empty, get_pending, get_current_version_after_migrate
demo.py is a demo script (0% coverage, 129 lines). __main__.py is entry point (0% coverage, 2 lines). Coverage: 80% → 81%
1. test_secrets: dotenv tests parametrized (9→7) 2. test_saga: compensation+retry+idempotency merged (13→9) 3. test_tools: layer+ops deleted, covered by tools_unit (14→12) 4. test_read_only: reduced to essential (9→4) 5. test_path_safety: backup+import_export parametrized (6→3) 6. test_middleware: reduced to essential (9→5)
Added test_features_coverage.py with tests for: - typed_export: import checks, main function - backup: list, restore_not_found, cleanup_old - audit_trail: log, history, count, cleanup, archive - rate_limiter: check, stats, cleanup - connection_limiter: acquire, release, user_limit, total_limit - agent_hooks: importance_gate, error_occurred, decision_made - wiki: add, count, list_by_type, list_all - backup_cron: backup_now, start_stop, status, restore Coverage: 80% → 82%
Added tests for: - backup_cron: restore_not_found, list_backups, status_details, state_persistence - wiki: agent_layer, disabled_type_raises, enabled_types Coverage: 82% → 83%
Added tests for: - saga: save/load state, cleanup state, compute_idempotency_key Coverage: 83%
|
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
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.
Summary
Test suite optimization: 364→250 tests, 80%→83% coverage, property-based expansion.
Changes
Deleted (10 files)
Parametrized (6 files)
Property-based expansion (25→39 tests)
Coverage tests (+32 tests)
Results
Verification