File size: 1,500 Bytes
2695a95
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#!/usr/bin/env python3
# Test context-aware variant search

import sys
import os
sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)))

# Import the updated function from app.py
from app import get_warehouse_stock

if __name__ == "__main__":
    test_cases = [
        "M Turuncu",           # Should find all M Turuncu variants
        "Marlin 6 M Turuncu",  # Should find only Marlin 6 M Turuncu variants
        "Marlin M Turuncu",    # Should find only Marlin M Turuncu variants
        "L Siyah",             # Should find all L Siyah variants
        "Marlin 6 L Siyah"     # Should find only Marlin 6 L Siyah variants
    ]
    
    for test_case in test_cases:
        print(f"\n=== Testing: {test_case} ===")
        try:
            result = get_warehouse_stock(test_case)
            if result:
                print("Sonuç:")
                total_stock = 0
                for item in result:
                    print(f"  • {item}")
                    # Extract stock count for total
                    if ": " in item and " adet" in item:
                        stock_part = item.split(": ")[1].replace(" adet", "")
                        try:
                            total_stock += int(stock_part)
                        except:
                            pass
                print(f"TOPLAM: {total_stock} adet")
            else:
                print("Sonuç bulunamadı")
        except Exception as e:
            print(f"Hata: {e}")
        print("-" * 50)