Files
StreamLens/simple_debug_test.py

86 lines
3.0 KiB
Python
Raw Permalink Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/usr/bin/env python3
"""
Simple test to trace button creation without running full TUI
"""
import sys
from pathlib import Path
# Add analyzer to path
sys.path.insert(0, str(Path(__file__).parent))
from analyzer.tui.textual.widgets.filtered_flow_view import FilteredFlowView
from analyzer.analysis.core import EthernetAnalyzer
def test_button_creation():
"""Test button creation step by step"""
print("🧪 Testing Button Creation Step-by-Step")
print("=" * 50)
# Create analyzer
print("1. Creating analyzer...")
analyzer = EthernetAnalyzer()
# Create FilteredFlowView
print("2. Creating FilteredFlowView...")
try:
view = FilteredFlowView(analyzer)
print(" ✅ FilteredFlowView created successfully")
print(f" ✅ Initial buttons dict: {len(view.frame_type_buttons)} entries")
for name, btn in view.frame_type_buttons.items():
print(f" - {name}: {btn}")
except Exception as e:
print(f" ❌ Failed to create FilteredFlowView: {e}")
import traceback
traceback.print_exc()
return False
# Test predefined frame types
print("3. Checking predefined frame types...")
print(f" ✅ Predefined types: {view.predefined_frame_types}")
# Test compose method (this is where buttons should be created)
print("4. Testing compose method...")
try:
# This would normally be called by Textual, but we can't easily test it
# without the full TUI framework
print(" ⚠️ Compose method can't be tested without TUI framework")
print(" This is where buttons should be created during widget composition")
except Exception as e:
print(f" ❌ Compose method failed: {e}")
# Test refresh_frame_types
print("5. Testing refresh_frame_types...")
try:
# This should be safe to call even without TUI
view.refresh_frame_types()
print(" ✅ refresh_frame_types completed without error")
except Exception as e:
print(f" ❌ refresh_frame_types failed: {e}")
import traceback
traceback.print_exc()
return True
def main():
print("🔍 Simple Debug Test for Button Issues")
print("This test checks button creation logic without running the full TUI")
print("=" * 60)
success = test_button_creation()
if success:
print("\n✅ Basic components created successfully")
print("\n🎯 Key Findings:")
print(" • FilteredFlowView can be instantiated")
print(" • Predefined frame types are configured")
print(" • refresh_frame_types can be called")
print("\n💡 Next Steps:")
print(" • The issue likely occurs during compose() or on_mount()")
print(" • These methods interact with the Textual widget system")
print(" • Need to debug within the running TUI app")
else:
print("\n❌ Issues found in basic component creation")
if __name__ == "__main__":
main()