Remove obsolete test scripts for DataTable details, status overlay, status positioning, status display, and status visibility

This commit is contained in:
Philip Henning 2025-07-31 10:23:40 +02:00
parent 25001042e5
commit 48e8e1c67c
5 changed files with 0 additions and 300 deletions

View file

@ -1,84 +0,0 @@
#!/usr/bin/env python3
"""
Quick test script to verify the new DataTable details functionality.
"""
import sys
from unittest.mock import patch, Mock
from src.hosts.tui.app import HostsManagerApp
from src.hosts.core.models import HostsFile, HostEntry
def test_datatable_details():
"""Test the new DataTable details functionality."""
print("Testing new DataTable details display...")
with patch('hosts.tui.app.HostsParser') as mock_parser_cls, \
patch('hosts.tui.app.Config') as mock_config_cls:
# Set up mocks
mock_parser = Mock()
mock_config = Mock()
mock_config.should_show_default_entries.return_value = True
mock_parser_cls.return_value = mock_parser
mock_config_cls.return_value = mock_config
# Create app
app = HostsManagerApp()
# Add test entries
app.hosts_file = HostsFile()
app.hosts_file.add_entry(HostEntry(
ip_address="127.0.0.1",
hostnames=["localhost"],
comment="Local machine",
is_active=True
))
app.hosts_file.add_entry(HostEntry(
ip_address="192.168.1.1",
hostnames=["router", "gateway"],
comment="Network router",
is_active=False
))
app.selected_entry_index = 0
# Test the details handler logic (without UI)
entry = app.hosts_file.entries[0]
# Verify entry details are in correct order (same as edit form)
expected_order = [
("IP Address", entry.ip_address),
("Hostnames", ", ".join(entry.hostnames)),
("Comment", entry.comment or ""),
("Active", "Yes" if entry.is_active else "No")
]
print("✓ Entry details order matches edit form:")
for field, value in expected_order:
print(f" - {field}: {value}")
# Test second entry
app.selected_entry_index = 1
entry2 = app.hosts_file.entries[1]
expected_order_2 = [
("IP Address", entry2.ip_address),
("Hostnames", ", ".join(entry2.hostnames)),
("Comment", entry2.comment or ""),
("Active", "Yes" if entry2.is_active else "No")
]
print("\n✓ Second entry details:")
for field, value in expected_order_2:
print(f" - {field}: {value}")
print("\n✅ DataTable details functionality verified!")
print("\n📋 Implementation details:")
print(" - Entry details now shown in DataTable with labeled rows")
print(" - Field order matches edit form: IP Address, Hostnames, Comment, Active")
print(" - DataTable uses show_header=False for clean appearance")
print(" - DNS Name shown when present (read-only field)")
print(" - System default entry warnings displayed in table format")
if __name__ == "__main__":
test_datatable_details()

View file

@ -1,56 +0,0 @@
#!/usr/bin/env python3
"""
Test script to verify the status bar overlay behavior.
"""
import asyncio
from unittest.mock import patch, Mock
from src.hosts.tui.app import HostsManagerApp
from src.hosts.core.models import HostsFile, HostEntry
async def test_status_overlay():
"""Test that the status bar appears as an overlay without affecting layout."""
print("Testing status bar overlay behavior...")
with patch('hosts.tui.app.HostsParser') as mock_parser_cls, \
patch('hosts.tui.app.Config') as mock_config_cls:
# Set up mocks
mock_parser = Mock()
mock_config = Mock()
mock_config.should_show_default_entries.return_value = True
mock_parser_cls.return_value = mock_parser
mock_config_cls.return_value = mock_config
# Create app
app = HostsManagerApp()
# Add test entries
app.hosts_file = HostsFile()
app.hosts_file.add_entry(HostEntry(
ip_address="127.0.0.1",
hostnames=["localhost"],
is_active=True
))
# Test status update with error message
app.update_status("❌ Test error message")
print("✓ Error message should appear as overlay")
print("✓ Panes should not shift down when message appears")
print("✓ Status bar positioned with dock: top, layer: overlay, offset: 3 0")
# Test clearing message
app._clear_status_message()
print("✓ Message clears and status bar becomes hidden")
print("\n✅ Status bar overlay test completed!")
print("\n📋 CSS Implementation:")
print(" - dock: top - positions at top of screen")
print(" - layer: overlay - renders above other content")
print(" - offset: 3 0 - positioned 3 lines down from top (below header)")
print(" - No layout flow impact - content stays in same position")
if __name__ == "__main__":
asyncio.run(test_status_overlay())

View file

@ -1,41 +0,0 @@
#!/usr/bin/env python3
"""
Test the status bar positioning by directly updating the app.
"""
import sys
from unittest.mock import patch, Mock
from src.hosts.tui.app import HostsManagerApp
from src.hosts.core.models import HostsFile, HostEntry
def test_status_positioning():
"""Test status bar positioning."""
print("Creating app instance and triggering error message...")
with patch('hosts.tui.app.HostsParser') as mock_parser_cls, \
patch('hosts.tui.app.Config') as mock_config_cls:
# Set up mocks
mock_parser = Mock()
mock_config = Mock()
mock_parser_cls.return_value = mock_parser
mock_config_cls.return_value = mock_config
# Create app
app = HostsManagerApp()
# Test that CSS is correct for positioning below header
print("✅ Status bar CSS updated:")
print(" - layer: overlay (renders above content)")
print(" - offset: 3 0 (positioned 3 lines from top)")
print(" - content-align: center middle (properly centered)")
print(" - Should appear below header without shifting content")
print("\n🎯 Positioning should now be:")
print(" Line 1: Header title area")
print(" Line 2: Header subtitle area")
print(" Line 3: Status bar overlay (when visible)")
print(" Line 4+: Main content panes")
if __name__ == "__main__":
test_status_positioning()

View file

@ -1,60 +0,0 @@
#!/usr/bin/env python3
"""
Quick test script to verify the new status display functionality.
"""
import sys
from unittest.mock import patch, Mock
from src.hosts.tui.app import HostsManagerApp
from src.hosts.core.models import HostsFile, HostEntry
def test_status_display():
"""Test the new status display functionality."""
print("Testing new status display...")
with patch('hosts.tui.app.HostsParser') as mock_parser_cls, \
patch('hosts.tui.app.Config') as mock_config_cls:
# Set up mocks
mock_parser = Mock()
mock_config = Mock()
mock_parser_cls.return_value = mock_parser
mock_config_cls.return_value = mock_config
# Create app
app = HostsManagerApp()
# Test title
print(f"✓ Title: '{app.title}' (should be '/etc/hosts Manager')")
assert app.title == "/etc/hosts Manager"
# Add some test entries
app.hosts_file = HostsFile()
app.hosts_file.add_entry(HostEntry(ip_address="127.0.0.1", hostnames=["localhost"]))
app.hosts_file.add_entry(HostEntry(ip_address="192.168.1.1", hostnames=["router"]))
app.hosts_file.add_entry(HostEntry(ip_address="10.0.0.1", hostnames=["server"], is_active=False))
# Test normal status update
app.update_status()
expected_subtitle = "3 entries (2 active) | Read-only mode"
print(f"✓ Subtitle: '{app.sub_title}' (should be '{expected_subtitle}')")
assert app.sub_title == expected_subtitle
# Test edit mode
app.edit_mode = True
app.update_status()
expected_subtitle = "3 entries (2 active) | Edit mode"
print(f"✓ Edit mode subtitle: '{app.sub_title}' (should be '{expected_subtitle}')")
assert app.sub_title == expected_subtitle
print("\n✅ All status display tests passed!")
# Test error message handling (would go to status bar)
print("\n📋 Status bar functionality:")
print(" - Error messages now appear in a status bar below the header")
print(" - Status bar is hidden by default and only shows when there are messages")
print(" - Messages auto-clear after 3-5 seconds")
print(" - Header subtitle always shows: 'X entries (Y active) | Mode'")
if __name__ == "__main__":
test_status_display()

View file

@ -1,59 +0,0 @@
#!/usr/bin/env python3
"""
Test status bar visibility by triggering an error message manually.
"""
import asyncio
from unittest.mock import patch, Mock
from src.hosts.tui.app import HostsManagerApp
async def test_status_bar_visibility():
"""Test that the status bar becomes visible when an error occurs."""
print("Testing status bar visibility...")
with patch('hosts.tui.app.HostsParser') as mock_parser_cls, \
patch('hosts.tui.app.Config') as mock_config_cls:
# Set up mocks
mock_parser = Mock()
mock_config = Mock()
mock_parser_cls.return_value = mock_parser
mock_config_cls.return_value = mock_config
# Create app
app = HostsManagerApp()
# Mock the query_one method to capture status bar interactions
mock_status_bar = Mock()
original_query_one = app.query_one
def mock_query_one(selector, widget_type=None):
if selector == "#status-bar":
return mock_status_bar
return original_query_one(selector, widget_type)
app.query_one = mock_query_one
# Test updating status with error message
print("🔧 Triggering error message...")
app.update_status("❌ Test error message")
# Verify status bar operations
print("✅ Status bar operations:")
print(f" - update() called: {mock_status_bar.update.called}")
print(f" - remove_class('hidden') called: {mock_status_bar.remove_class.called}")
if mock_status_bar.update.called:
call_args = mock_status_bar.update.call_args[0]
print(f" - Message passed: '{call_args[0]}'")
# Test clearing status
print("\n🔧 Clearing status message...")
app._clear_status_message()
print("✅ Clear operations:")
print(f" - update('') called: {mock_status_bar.update.call_count > 1}")
print(f" - add_class('hidden') called: {mock_status_bar.add_class.called}")
if __name__ == "__main__":
asyncio.run(test_status_bar_visibility())