feat: add comprehensive tests for duty schedule import and error handling
All checks were successful
CI / lint-and-test (push) Successful in 23s
All checks were successful
CI / lint-and-test (push) Successful in 23s
- Introduced new tests for the `import_duty_schedule_cmd` to verify behavior when no message or effective user is present, ensuring proper early returns. - Added tests for admin checks to confirm that only authorized users can initiate duty schedule imports, enhancing security. - Implemented error handling tests for the `handle_handover_time_text` function to ensure appropriate responses for invalid time formats and non-admin users. - Enhanced overall test coverage for the duty schedule import functionality, contributing to improved reliability and maintainability of the codebase. - Updated the `.coverage` file to reflect the latest coverage metrics.
This commit is contained in:
@@ -57,6 +57,7 @@ async def test_error_handler_update_none_does_not_crash():
|
||||
@pytest.mark.asyncio
|
||||
async def test_error_handler_reply_text_raises_does_not_propagate():
|
||||
"""error_handler: when reply_text raises, exception is caught and logged; does not propagate."""
|
||||
|
||||
class FakeUpdate:
|
||||
pass
|
||||
|
||||
@@ -71,7 +72,9 @@ async def test_error_handler_reply_text_raises_does_not_propagate():
|
||||
|
||||
with patch("duty_teller.handlers.errors.Update", FakeUpdate):
|
||||
with patch("duty_teller.handlers.errors.get_lang", return_value="en"):
|
||||
with patch("duty_teller.handlers.errors.t", return_value="An error occurred."):
|
||||
with patch(
|
||||
"duty_teller.handlers.errors.t", return_value="An error occurred."
|
||||
):
|
||||
await error_handler(update, context)
|
||||
# Handler must not raise; reply_text was attempted
|
||||
update.effective_message.reply_text.assert_called_once()
|
||||
|
||||
Reference in New Issue
Block a user