Fix issue1: Hide zero-hour days by default and add toggle option in menu

This commit is contained in:
Daniel Dybing
2026-03-14 11:52:31 +01:00
parent 1a09921fcc
commit d0196fefd0
2 changed files with 50 additions and 3 deletions

View File

@@ -41,6 +41,33 @@ class TestTamigoExport(unittest.TestCase):
self.assertIn("2025-03-10", work_days)
self.assertEqual(work_days["2025-03-10"]["hours"], 8.0)
def test_get_worked_days_zero_hour_filtering(self):
# Mock API response with a 0-hour shift (missing EndTime so it stays 0)
mock_shifts = [
{
"Date": "/Date(1741564800000)/", # 2025-03-10
"StartTime": "2025-03-10T09:00:00Z",
"ActualShiftHours": 0,
"ActualShiftText": "Sick Day",
"IsAbsent": False
}
]
self.client.get_employee_actual_shifts.return_value = mock_shifts
start_date = datetime(2025, 3, 1)
end_date = datetime(2025, 3, 15)
# 1. Test with show_zero_hours = False (Default)
with patch('tamigo.console'), patch('tamigo.current_config', {'show_zero_hours': False}):
work_days = get_worked_days(self.client, start_date, end_date)
self.assertEqual(len(work_days), 0)
# 2. Test with show_zero_hours = True
with patch('tamigo.console'), patch('tamigo.current_config', {'show_zero_hours': True}):
work_days = get_worked_days(self.client, start_date, end_date)
self.assertEqual(len(work_days), 1)
self.assertIn("2025-03-10", work_days)
self.assertEqual(work_days["2025-03-10"]["hours"], 0)
@patch('tamigo.select_date_range')
@patch('tamigo.get_worked_days')
@patch('questionary.select')