bmc_hub/tests/test_bottom_bar_timer_pause.py
Christian 4871dd2d9e Add comprehensive test coverage for various modules
- Introduced tests for mail templates including ranking, rendering, and attachment handling.
- Added tests for time billing selection and approval processes, ensuring proper validation and state management.
- Implemented tests for case types in JavaScript, focusing on loading and editing functionality.
- Created tests for contact mail AI integration, ensuring proper parsing and error handling.
- Developed tests for dark theme CSS contrast and loading order.
- Added tests for invoice fee service, covering various scenarios including exemptions and invalid inputs.
- Implemented vendor resource tests, ensuring proper file handling and query validation.
2026-10-08 08:58:02 +02:00

31 lines
1.4 KiB
Python

from app.modules.bottom_bar.backend import service
def test_active_timer_deducts_previous_pauses(monkeypatch):
def query(sql,params):
assert 'COALESCE(t.pause_total_seconds, 0)' in sql
assert 'GREATEST' in sql
return {'id':3,'sag_id':186,'elapsed':240}
monkeypatch.setattr(service,'execute_query_single',query)
result=service.get_active_timer(12)
assert result['elapsed']==240
assert result['elapsed_hhmmss']=='00:04:00'
def test_paused_timer_freezes_at_pause_time_and_deducts_prior_pauses(monkeypatch):
monkeypatch.setattr(service,'get_active_timer',lambda user:{'active':False})
monkeypatch.setattr(service,'execute_query_single',lambda *args:{'count':1})
def query(sql,params):
assert 'COALESCE(t.paused_at, NOW())' in sql
return [{'id':3,'sag_id':186,'elapsed_seconds':300,'pause_total_seconds':60}]
monkeypatch.setattr(service,'execute_query',query)
result=service.get_own_timer_snapshot(12)
assert result['paused'][0]['elapsed_hhmmss']=='00:04:00'
def test_pause_display_never_goes_negative(monkeypatch):
monkeypatch.setattr(service,'get_active_timer',lambda user:{'active':False})
monkeypatch.setattr(service,'execute_query_single',lambda *args:{'count':1})
monkeypatch.setattr(service,'execute_query',lambda *args:[{'id':3,'elapsed_seconds':10,'pause_total_seconds':60}])
assert service.get_own_timer_snapshot(12)['paused'][0]['elapsed_hhmmss']=='00:00:00'