Skip to content

test: optimize test suite — 364→250 tests, 83% coverage - #61

Merged
Cipher208 merged 19 commits into
masterfrom
test-optimization-v2
Jul 6, 2026
Merged

test: optimize test suite — 364→250 tests, 83% coverage#61
Cipher208 merged 19 commits into
masterfrom
test-optimization-v2

Conversation

@Cipher208

Copy link
Copy Markdown
Owner

Summary

Test suite optimization: 364→250 tests, 80%→83% coverage, property-based expansion.

Changes

Deleted (10 files)

  • test_all.py, test_mcp/test_mcp.py, test_lifecycle, test_hooks, test_graph, test_rag, test_rag_edge_cases
  • test_tools_layer.py, test_tools_ops.py, test_saga_compensation/retry/idempotency

Parametrized (6 files)

  • test_rag_scoring, test_rag_search_facade, test_memory_types, test_importance_v2, test_mib_quantize, test_tools_unit

Property-based expansion (25→39 tests)

  • ImportanceGate, MemoryTypes, PathSafety, Saga, Connection, Cache, Embeddings, Secrets

Coverage tests (+32 tests)

  • typed_export, backup, audit_trail, rate_limiting, agent_hooks, wiki, backup_cron, saga

Results

Metric Before After
Tests 364 250
Coverage 80% 83%
Property-based 25 39
Files 65 52

Verification

  • All tests pass (250/250)
  • ruff: 0 errors
  • Coverage: 83%

Ariel Memory 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-commenter

Copy link
Copy Markdown

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@Cipher208
Cipher208 merged commit b7a80cb into master Jul 6, 2026
18 checks passed
@Cipher208
Cipher208 deleted the test-optimization-v2 branch July 6, 2026 12:49
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.

2 participants