57 lines
2.4 KiB
Python
57 lines
2.4 KiB
Python
|
|
#!/usr/bin/env python3
|
||
|
|
|
||
|
|
from data_comparator import KSTCoordiComparator
|
||
|
|
|
||
|
|
def test_sheet_filtering():
|
||
|
|
"""Test that sheet filtering works correctly and defaults to first sheet"""
|
||
|
|
print("Testing sheet filtering functionality...")
|
||
|
|
|
||
|
|
# Create comparator and load data
|
||
|
|
comparator = KSTCoordiComparator("data/sample-data.xlsx")
|
||
|
|
if not comparator.load_data():
|
||
|
|
print("Failed to load data!")
|
||
|
|
return
|
||
|
|
|
||
|
|
print(f"Available sheets: {list(comparator.data.keys())}")
|
||
|
|
|
||
|
|
# Test 1: No sheet filter provided (should default to first sheet)
|
||
|
|
print("\n=== TEST 1: No sheet filter (should default to first sheet) ===")
|
||
|
|
try:
|
||
|
|
summary1 = comparator.get_comparison_summary()
|
||
|
|
print(f"Default sheet selected: {summary1['current_sheet_filter']}")
|
||
|
|
print(f"KST total: {summary1['original_counts']['kst_total']}")
|
||
|
|
print(f"Coordi total: {summary1['original_counts']['coordi_total']}")
|
||
|
|
print(f"Matched: {summary1['matched_items_count']}")
|
||
|
|
print("✓ Test 1 passed")
|
||
|
|
except Exception as e:
|
||
|
|
print(f"✗ Test 1 failed: {e}")
|
||
|
|
|
||
|
|
# Test 2: Specific sheet filter
|
||
|
|
sheet_names = list(comparator.data.keys())
|
||
|
|
if len(sheet_names) > 1:
|
||
|
|
second_sheet = sheet_names[1]
|
||
|
|
print(f"\n=== TEST 2: Specific sheet filter ({second_sheet}) ===")
|
||
|
|
try:
|
||
|
|
summary2 = comparator.get_comparison_summary(second_sheet)
|
||
|
|
print(f"Selected sheet: {summary2['current_sheet_filter']}")
|
||
|
|
print(f"KST total: {summary2['original_counts']['kst_total']}")
|
||
|
|
print(f"Coordi total: {summary2['original_counts']['coordi_total']}")
|
||
|
|
print(f"Matched: {summary2['matched_items_count']}")
|
||
|
|
print("✓ Test 2 passed")
|
||
|
|
except Exception as e:
|
||
|
|
print(f"✗ Test 2 failed: {e}")
|
||
|
|
else:
|
||
|
|
print("\n=== TEST 2: Skipped (only one sheet available) ===")
|
||
|
|
|
||
|
|
# Test 3: Verify no duplicates across sheets (this was the original problem)
|
||
|
|
print(f"\n=== TEST 3: Verify duplicate detection within single sheets only ===")
|
||
|
|
for sheet_name in sheet_names:
|
||
|
|
summary = comparator.get_comparison_summary(sheet_name)
|
||
|
|
print(f"Sheet '{sheet_name}':")
|
||
|
|
print(f" KST duplicates: {summary['mismatches']['kst_duplicates_count']}")
|
||
|
|
print(f" Coordi duplicates: {summary['mismatches']['coordi_duplicates_count']}")
|
||
|
|
|
||
|
|
print("\n✓ All tests completed!")
|
||
|
|
|
||
|
|
if __name__ == "__main__":
|
||
|
|
test_sheet_filtering()
|