Initial commit: 2125_GCE project
This commit is contained in:
Executable
+169
@@ -0,0 +1,169 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Test glyph_explorer.py with automated tests."""
|
||||
|
||||
import sys
|
||||
from pathlib import Path
|
||||
|
||||
sys.path.insert(0, str(Path(__file__).parent))
|
||||
|
||||
from glyph_explorer import GlyphExplorer
|
||||
|
||||
|
||||
def test_list_glyphs():
|
||||
"""Test listing glyphs."""
|
||||
print("Test: List glyphs")
|
||||
explorer = GlyphExplorer()
|
||||
glyphs = explorer.list_all_glyphs(20)
|
||||
|
||||
if len(glyphs) != 20:
|
||||
print(f"FAIL: Expected 20 glyphs, got {len(glyphs)}")
|
||||
return False
|
||||
|
||||
# Check G001 is first
|
||||
if glyphs[0]["id"] != "G001":
|
||||
print(f"FAIL: First glyph should be G001, got {glyphs[0]['id']}")
|
||||
return False
|
||||
|
||||
# Check G001 has 152 powers
|
||||
if glyphs[0]["power_count"] != 152:
|
||||
print(f"FAIL: G001 should have 152 powers, got {glyphs[0]['power_count']}")
|
||||
return False
|
||||
|
||||
print(f"PASS: Listed {len(glyphs)} glyphs, G001 has {glyphs[0]['power_count']} powers")
|
||||
return True
|
||||
|
||||
|
||||
def test_show_glyph_details():
|
||||
"""Test showing glyph details."""
|
||||
print("\nTest: Show glyph details")
|
||||
explorer = GlyphExplorer()
|
||||
|
||||
result = explorer.show_glyph_details("G001")
|
||||
if not result:
|
||||
print("FAIL: Could not show G001 details")
|
||||
return False
|
||||
|
||||
print("PASS: G001 details displayed")
|
||||
return True
|
||||
|
||||
|
||||
def test_show_all_superpowers():
|
||||
"""Test showing all superpowers."""
|
||||
print("\nTest: Show all superpowers")
|
||||
explorer = GlyphExplorer()
|
||||
|
||||
result = explorer.show_all_superpowers(50)
|
||||
if not result:
|
||||
print("FAIL: Could not show superpowers")
|
||||
return False
|
||||
|
||||
print("PASS: Superpowers displayed")
|
||||
return True
|
||||
|
||||
|
||||
def test_g001_activation():
|
||||
"""Test G001 activation."""
|
||||
print("\nTest: G001 activation")
|
||||
explorer = GlyphExplorer()
|
||||
|
||||
result = explorer.test_g001_activation()
|
||||
if not result:
|
||||
print("FAIL: G001 activation test failed")
|
||||
return False
|
||||
|
||||
print("PASS: G001 activation test passed")
|
||||
return True
|
||||
|
||||
|
||||
def test_power_boost():
|
||||
"""Test power boost calculations."""
|
||||
print("\nTest: Power boost calculations")
|
||||
explorer = GlyphExplorer()
|
||||
|
||||
result = explorer.test_power_boost_calculation()
|
||||
if not result:
|
||||
print("FAIL: Power boost test failed")
|
||||
return False
|
||||
|
||||
print("PASS: Power boost calculations verified")
|
||||
return True
|
||||
|
||||
|
||||
def test_specialized_types():
|
||||
"""Test specialized types distribution."""
|
||||
print("\nTest: Specialized types distribution")
|
||||
explorer = GlyphExplorer()
|
||||
|
||||
result = explorer.show_specialized_types()
|
||||
if not result:
|
||||
print("FAIL: Could not show specialized types")
|
||||
return False
|
||||
|
||||
counts = explorer.get_specialized_types()
|
||||
total = sum(counts.values())
|
||||
|
||||
if total != 600:
|
||||
print(f"FAIL: Expected 600 glyphs total, got {total}")
|
||||
return False
|
||||
|
||||
print(f"PASS: Specialized types distribution shown ({total} glyphs)")
|
||||
return True
|
||||
|
||||
|
||||
def test_search_glyphs():
|
||||
"""Test searching glyphs."""
|
||||
print("\nTest: Search glyphs")
|
||||
explorer = GlyphExplorer()
|
||||
|
||||
results = explorer.search_glyphs("ledo")
|
||||
|
||||
if len(results) == 0:
|
||||
print("FAIL: Search returned no results")
|
||||
return False
|
||||
|
||||
if results[0]["id"] != "G001":
|
||||
print(f"FAIL: First result should be G001, got {results[0]['id']}")
|
||||
return False
|
||||
|
||||
print(f"PASS: Search found {len(results)} glyphs, first is {results[0]['id']}")
|
||||
return True
|
||||
|
||||
|
||||
def main():
|
||||
"""Run all tests."""
|
||||
print("=" * 70)
|
||||
print("GLYPH EXPLORER TEST SUITE")
|
||||
print("=" * 70)
|
||||
|
||||
tests = [
|
||||
("List glyphs", test_list_glyphs),
|
||||
("Show glyph details", test_show_glyph_details),
|
||||
("Show superpowers", test_show_all_superpowers),
|
||||
("G001 activation", test_g001_activation),
|
||||
("Power boost", test_power_boost),
|
||||
("Specialized types", test_specialized_types),
|
||||
("Search glyphs", test_search_glyphs),
|
||||
]
|
||||
|
||||
passed = 0
|
||||
failed = 0
|
||||
|
||||
for name, test_func in tests:
|
||||
try:
|
||||
if test_func():
|
||||
passed += 1
|
||||
else:
|
||||
failed += 1
|
||||
except Exception as e:
|
||||
print(f"FAIL: {name} - {e}")
|
||||
failed += 1
|
||||
|
||||
print("\n" + "=" * 70)
|
||||
print(f"RESULTS: {passed}/{len(tests)} passed")
|
||||
print("=" * 70)
|
||||
|
||||
return 0 if failed == 0 else 1
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
sys.exit(main())
|
||||
Reference in New Issue
Block a user