Implement HostsManager for managing hosts file edits with permission handling
- Added PermissionManager class for managing sudo permissions. - Introduced HostsManager class for high-level operations on hosts file. - Implemented methods for entering/exiting edit mode, toggling entries, moving entries, updating entries, saving the hosts file, and restoring backups. - Integrated permission validation and backup creation during edit operations. - Enhanced main application to support edit mode and associated actions. - Added tests for PermissionManager and HostsManager to ensure functionality and error handling.
This commit is contained in:
parent
fa7e7718c9
commit
1b57be2cbf
5 changed files with 1247 additions and 53 deletions
|
@ -376,6 +376,9 @@ class TestHostsManagerApp:
|
|||
app = HostsManagerApp()
|
||||
app.update_entry_details = Mock()
|
||||
|
||||
# Mock the display_index_to_actual_index method to return the same index
|
||||
app.display_index_to_actual_index = Mock(return_value=2)
|
||||
|
||||
# Create mock event with required parameters
|
||||
mock_table = Mock()
|
||||
mock_table.id = "entries-table"
|
||||
|
@ -388,6 +391,7 @@ class TestHostsManagerApp:
|
|||
# Should update selected index and details
|
||||
assert app.selected_entry_index == 2
|
||||
app.update_entry_details.assert_called_once()
|
||||
app.display_index_to_actual_index.assert_called_once_with(2)
|
||||
|
||||
def test_data_table_header_selected_ip_column(self):
|
||||
"""Test DataTable header selection for IP column."""
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue