[AI] fix
This commit is contained in:
@@ -9,10 +9,19 @@ def test_overlay_window_creation():
|
||||
root = tk.Tk()
|
||||
root.withdraw() # Hide the root window
|
||||
|
||||
# Mock dependencies
|
||||
# Mock dependencies with proper return values
|
||||
mock_tracker = Mock()
|
||||
mock_config = Mock()
|
||||
mock_tracker.get_current_session_duration.return_value = 0
|
||||
mock_tracker.get_total_work_today.return_value = 0
|
||||
mock_tracker.get_planned_duration.return_value = None
|
||||
mock_tracker.active_window = 'Desktop'
|
||||
mock_tracker.window_classification = 'neutral'
|
||||
|
||||
mock_config = Mock()
|
||||
mock_config.tracking_enabled = True
|
||||
mock_config.current_task_id = None
|
||||
|
||||
# Create overlay - this should not raise an exception
|
||||
overlay = OverlayWindow(root, mock_tracker, mock_config)
|
||||
|
||||
# Check that window properties are set
|
||||
@@ -32,21 +41,25 @@ def test_update_display_with_active_task():
|
||||
root = tk.Tk()
|
||||
root.withdraw()
|
||||
|
||||
# Mock dependencies with proper return values
|
||||
mock_tracker = Mock()
|
||||
mock_config = Mock()
|
||||
|
||||
# Set up mock returns
|
||||
mock_config.tracking_enabled = True
|
||||
mock_config.current_task_id = 'PRJ-123'
|
||||
mock_tracker.get_current_session_duration.return_value = 3600 # 1 hour
|
||||
mock_tracker.get_total_work_today.return_value = 7200 # 2 hours
|
||||
mock_tracker.get_planned_duration.return_value = None
|
||||
mock_tracker.active_window = 'PyCharm'
|
||||
mock_tracker.window_classification = 'work'
|
||||
|
||||
mock_config = Mock()
|
||||
mock_config.tracking_enabled = True
|
||||
mock_config.current_task_id = 'PRJ-123'
|
||||
|
||||
overlay = OverlayWindow(root, mock_tracker, mock_config)
|
||||
overlay.update_display()
|
||||
|
||||
# Check that labels were updated (we can check the text property)
|
||||
assert 'PRJ-123' in overlay.task_label.cget('text')
|
||||
assert '1ч00м' in overlay.status_label.cget('text')
|
||||
# The task label should contain the duration, not the status label
|
||||
assert '1ч00м' in overlay.task_label.cget('text')
|
||||
|
||||
root.destroy()
|
||||
|
||||
@@ -56,14 +69,17 @@ def test_update_display_without_active_task():
|
||||
root = tk.Tk()
|
||||
root.withdraw()
|
||||
|
||||
# Mock dependencies with proper return values
|
||||
mock_tracker = Mock()
|
||||
mock_config = Mock()
|
||||
|
||||
# Set up mock returns
|
||||
mock_config.tracking_enabled = True
|
||||
mock_config.current_task_id = None
|
||||
mock_tracker.get_current_session_duration.return_value = 0
|
||||
mock_tracker.get_total_work_today.return_value = 0
|
||||
mock_tracker.get_planned_duration.return_value = None
|
||||
mock_tracker.active_window = 'Desktop'
|
||||
mock_tracker.window_classification = 'neutral'
|
||||
|
||||
mock_config = Mock()
|
||||
mock_config.tracking_enabled = True
|
||||
mock_config.current_task_id = None
|
||||
|
||||
overlay = OverlayWindow(root, mock_tracker, mock_config)
|
||||
overlay.update_display()
|
||||
@@ -79,8 +95,17 @@ def test_toggle_tracking_callback():
|
||||
root = tk.Tk()
|
||||
root.withdraw()
|
||||
|
||||
# Mock dependencies with proper return values
|
||||
mock_tracker = Mock()
|
||||
mock_tracker.get_current_session_duration.return_value = 0
|
||||
mock_tracker.get_total_work_today.return_value = 0
|
||||
mock_tracker.get_planned_duration.return_value = None
|
||||
mock_tracker.active_window = 'Desktop'
|
||||
mock_tracker.window_classification = 'neutral'
|
||||
|
||||
mock_config = Mock()
|
||||
mock_config.tracking_enabled = True
|
||||
mock_config.current_task_id = None
|
||||
|
||||
overlay = OverlayWindow(root, mock_tracker, mock_config)
|
||||
|
||||
@@ -98,8 +123,17 @@ def test_new_task_callback():
|
||||
root = tk.Tk()
|
||||
root.withdraw()
|
||||
|
||||
# Mock dependencies with proper return values
|
||||
mock_tracker = Mock()
|
||||
mock_tracker.get_current_session_duration.return_value = 0
|
||||
mock_tracker.get_total_work_today.return_value = 0
|
||||
mock_tracker.get_planned_duration.return_value = None
|
||||
mock_tracker.active_window = 'Desktop'
|
||||
mock_tracker.window_classification = 'neutral'
|
||||
|
||||
mock_config = Mock()
|
||||
mock_config.tracking_enabled = True
|
||||
mock_config.current_task_id = None
|
||||
|
||||
overlay = OverlayWindow(root, mock_tracker, mock_config)
|
||||
|
||||
@@ -119,14 +153,21 @@ def test_switch_task_callback():
|
||||
root = tk.Tk()
|
||||
root.withdraw()
|
||||
|
||||
# Mock dependencies with proper return values
|
||||
mock_tracker = Mock()
|
||||
mock_tracker.get_current_session_duration.return_value = 0
|
||||
mock_tracker.get_total_work_today.return_value = 0
|
||||
mock_tracker.get_planned_duration.return_value = None
|
||||
mock_tracker.active_window = 'Desktop'
|
||||
mock_tracker.window_classification = 'neutral'
|
||||
mock_tracker.get_available_tasks.return_value = ['TASK-1', 'TASK-2', 'TASK-3']
|
||||
|
||||
mock_config = Mock()
|
||||
mock_config.tracking_enabled = True
|
||||
mock_config.current_task_id = None
|
||||
|
||||
overlay = OverlayWindow(root, mock_tracker, mock_config)
|
||||
|
||||
# Mock the available tasks
|
||||
mock_tracker.get_available_tasks.return_value = ['TASK-1', 'TASK-2', 'TASK-3']
|
||||
|
||||
# Mock the selection dialog
|
||||
with patch('tkinter.simpledialog.askstring') as mock_dialog:
|
||||
mock_dialog.return_value = 'TASK-2'
|
||||
@@ -143,8 +184,17 @@ def test_adjust_time_callback():
|
||||
root = tk.Tk()
|
||||
root.withdraw()
|
||||
|
||||
# Mock dependencies with proper return values
|
||||
mock_tracker = Mock()
|
||||
mock_tracker.get_current_session_duration.return_value = 0
|
||||
mock_tracker.get_total_work_today.return_value = 0
|
||||
mock_tracker.get_planned_duration.return_value = None
|
||||
mock_tracker.active_window = 'Desktop'
|
||||
mock_tracker.window_classification = 'neutral'
|
||||
|
||||
mock_config = Mock()
|
||||
mock_config.tracking_enabled = True
|
||||
mock_config.current_task_id = None
|
||||
|
||||
overlay = OverlayWindow(root, mock_tracker, mock_config)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user