mirror of
https://github.com/mwisnowski/mtg_python_deckbuilder.git
synced 2025-09-22 04:50:46 +02:00
feat: complete include/exclude observability, fix validation bugs, and organize tests
- Add structured logging for include/exclude operations with comprehensive event tracking - Fix duplicate counting bug in validation API by eliminating double validation passes - Simplify color identity validation UX by consolidating into single 'illegal' status - Organize project structure by moving all test files to centralized code/tests/ directory - Update documentation reflecting feature completion and production readiness - Add validation test scripts and performance benchmarks confirming targets met - Finalize include/exclude feature as production-ready with EDH format compliance
This commit is contained in:
parent
f77bce14cb
commit
3e4395d6e9
32 changed files with 470 additions and 89 deletions
83
code/tests/test_fuzzy_logic.py
Normal file
83
code/tests/test_fuzzy_logic.py
Normal file
|
@ -0,0 +1,83 @@
|
|||
#!/usr/bin/env python3
|
||||
"""
|
||||
Direct test of fuzzy matching functionality.
|
||||
"""
|
||||
|
||||
import sys
|
||||
import os
|
||||
sys.path.insert(0, os.path.join(os.path.dirname(__file__), 'code'))
|
||||
|
||||
from deck_builder.include_exclude_utils import fuzzy_match_card_name
|
||||
|
||||
def test_fuzzy_matching_direct():
|
||||
"""Test fuzzy matching directly."""
|
||||
print("🔍 Testing fuzzy matching directly...")
|
||||
|
||||
# Create a small set of available cards
|
||||
available_cards = {
|
||||
'Lightning Bolt',
|
||||
'Lightning Strike',
|
||||
'Lightning Helix',
|
||||
'Chain Lightning',
|
||||
'Sol Ring',
|
||||
'Mana Crypt'
|
||||
}
|
||||
|
||||
# Test with typo that should trigger low confidence
|
||||
result = fuzzy_match_card_name('Lighning', available_cards) # Worse typo
|
||||
|
||||
print("Input: 'Lighning'")
|
||||
print(f"Matched name: {result.matched_name}")
|
||||
print(f"Auto accepted: {result.auto_accepted}")
|
||||
print(f"Confidence: {result.confidence:.2%}")
|
||||
print(f"Suggestions: {result.suggestions}")
|
||||
|
||||
if result.matched_name is None and not result.auto_accepted and result.suggestions:
|
||||
print("✅ Fuzzy matching correctly triggered confirmation!")
|
||||
return True
|
||||
else:
|
||||
print("❌ Fuzzy matching should have triggered confirmation")
|
||||
return False
|
||||
|
||||
def test_exact_match_direct():
|
||||
"""Test exact matching directly."""
|
||||
print("\n🎯 Testing exact match directly...")
|
||||
|
||||
available_cards = {
|
||||
'Lightning Bolt',
|
||||
'Lightning Strike',
|
||||
'Lightning Helix',
|
||||
'Sol Ring'
|
||||
}
|
||||
|
||||
result = fuzzy_match_card_name('Lightning Bolt', available_cards)
|
||||
|
||||
print(f"Input: 'Lightning Bolt'")
|
||||
print(f"Matched name: {result.matched_name}")
|
||||
print(f"Auto accepted: {result.auto_accepted}")
|
||||
print(f"Confidence: {result.confidence:.2%}")
|
||||
|
||||
if result.matched_name and result.auto_accepted:
|
||||
print("✅ Exact match correctly auto-accepted!")
|
||||
return True
|
||||
else:
|
||||
print("❌ Exact match should have been auto-accepted")
|
||||
return False
|
||||
|
||||
if __name__ == "__main__":
|
||||
print("🧪 Testing Fuzzy Matching Logic")
|
||||
print("=" * 40)
|
||||
|
||||
test1_pass = test_fuzzy_matching_direct()
|
||||
test2_pass = test_exact_match_direct()
|
||||
|
||||
print("\n📋 Test Summary:")
|
||||
print(f" Fuzzy confirmation: {'✅ PASS' if test1_pass else '❌ FAIL'}")
|
||||
print(f" Exact match: {'✅ PASS' if test2_pass else '❌ FAIL'}")
|
||||
|
||||
if test1_pass and test2_pass:
|
||||
print("\n🎉 Fuzzy matching logic working correctly!")
|
||||
else:
|
||||
print("\n🔧 Issues found in fuzzy matching logic")
|
||||
|
||||
exit(0 if test1_pass and test2_pass else 1)
|
Loading…
Add table
Add a link
Reference in a new issue