updates
This commit is contained in:
82
test_widget_direct.py
Normal file
82
test_widget_direct.py
Normal file
@@ -0,0 +1,82 @@
|
||||
"""Direct test of widget mounting and data loading."""
|
||||
|
||||
import asyncio
|
||||
import sys
|
||||
from pathlib import Path
|
||||
|
||||
# Add src to path
|
||||
sys.path.insert(0, str(Path(__file__).parent / "src"))
|
||||
|
||||
from jellycleanarr.config import settings
|
||||
from jellycleanarr.api.client import JellyfinClient
|
||||
from jellycleanarr.ui.widgets.user_stats import UserStatsWidget
|
||||
from jellycleanarr.ui.widgets.stats_table import StatsTable
|
||||
|
||||
|
||||
async def test_widget():
|
||||
"""Test widget creation and data loading."""
|
||||
print("Creating Jellyfin client...")
|
||||
client = JellyfinClient(settings.jellyfin_address, settings.jellyfin_api_key)
|
||||
|
||||
try:
|
||||
await client.test_connection()
|
||||
print("[OK] Connected to Jellyfin")
|
||||
|
||||
# Create the widget
|
||||
print("\nCreating UserStatsWidget...")
|
||||
widget = UserStatsWidget(client)
|
||||
|
||||
# Manually call compose to create child widgets
|
||||
print("Calling compose()...")
|
||||
widgets = list(widget.compose())
|
||||
print(f"[OK] Compose created {len(widgets)} widgets")
|
||||
|
||||
for i, w in enumerate(widgets):
|
||||
print(f" Widget {i}: {type(w).__name__}")
|
||||
if hasattr(w, 'compose'):
|
||||
children = list(w.compose())
|
||||
for j, child in enumerate(children):
|
||||
print(f" Child {j}: {type(child).__name__} - id={getattr(child, 'id', 'no-id')}")
|
||||
|
||||
# Try to manually create and populate a table
|
||||
print("\nManually creating StatsTable...")
|
||||
table = StatsTable(
|
||||
"Test Table",
|
||||
columns=[
|
||||
("User", 20),
|
||||
("Plays", 12),
|
||||
("Duration", 15),
|
||||
("Items", 13),
|
||||
],
|
||||
id="test-table",
|
||||
)
|
||||
|
||||
# Simulate on_mount
|
||||
print("Simulating table on_mount (adding columns)...")
|
||||
for col_name, col_width in table._columns_config:
|
||||
table.add_column(col_name, width=col_width)
|
||||
table._columns_added = True
|
||||
print(f"[OK] Table has {len(table.columns)} columns")
|
||||
|
||||
# Add test data
|
||||
print("Adding test rows...")
|
||||
test_rows = [
|
||||
["HRiggs", "346", "3h 9m", "153"],
|
||||
["TV", "204", "5d 1h 16m", "115"],
|
||||
]
|
||||
table.update_data(test_rows)
|
||||
print(f"[OK] Table has {table.row_count} rows")
|
||||
|
||||
print("\n=== Widget structure looks OK ===")
|
||||
print("The issue might be in the async mounting order or Textual rendering.")
|
||||
|
||||
except Exception as e:
|
||||
print(f"\nERROR: {e}")
|
||||
import traceback
|
||||
traceback.print_exc()
|
||||
finally:
|
||||
await client.close()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
asyncio.run(test_widget())
|
||||
Reference in New Issue
Block a user