From 48e8e1c67c7ac3f062941d6d444faf9ead37c247 Mon Sep 17 00:00:00 2001 From: phg Date: Thu, 31 Jul 2025 10:23:40 +0200 Subject: [PATCH] Remove obsolete test scripts for DataTable details, status overlay, status positioning, status display, and status visibility --- test_datatable.py | 84 --------------------------------------- test_overlay.py | 56 -------------------------- test_position.py | 41 ------------------- test_status.py | 60 ---------------------------- test_status_visibility.py | 59 --------------------------- 5 files changed, 300 deletions(-) delete mode 100644 test_datatable.py delete mode 100644 test_overlay.py delete mode 100644 test_position.py delete mode 100644 test_status.py delete mode 100644 test_status_visibility.py diff --git a/test_datatable.py b/test_datatable.py deleted file mode 100644 index b6abf82..0000000 --- a/test_datatable.py +++ /dev/null @@ -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() diff --git a/test_overlay.py b/test_overlay.py deleted file mode 100644 index 737bd1b..0000000 --- a/test_overlay.py +++ /dev/null @@ -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()) diff --git a/test_position.py b/test_position.py deleted file mode 100644 index a90df3b..0000000 --- a/test_position.py +++ /dev/null @@ -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() diff --git a/test_status.py b/test_status.py deleted file mode 100644 index 088f5ed..0000000 --- a/test_status.py +++ /dev/null @@ -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() diff --git a/test_status_visibility.py b/test_status_visibility.py deleted file mode 100644 index 968dcd5..0000000 --- a/test_status_visibility.py +++ /dev/null @@ -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())