#!/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()