Skip to content

Commit

Permalink
Fix main test
Browse files Browse the repository at this point in the history
  • Loading branch information
thecarrot123 committed Apr 29, 2024
1 parent ec3400c commit b3489ab
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions tests/test_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,9 @@ def test_main_command_handler():
"""
with patch("app.bot.init_db"), patch(
"app.bot.Application.builder"
) as mock_builder, patch("app.bot.CommandHandler") as mock_command_handler, patch(
) as mock_builder, patch(
"app.bot.CommandHandler"
) as mock_command_handler, patch(
"app.bot.run_notifiers"
), patch(
"app.bot.Thread"
Expand Down Expand Up @@ -79,12 +81,14 @@ def test_main_threading():
thread for running notifiers is correctly initiated. Ensures the thread
starts as expected, which is crucial for background tasks.
"""
with patch("app.bot.init_db"), patch("app.bot.Application.builder"), patch(
"app.bot.run_notifiers"
), patch("app.bot.Thread") as mock_thread, patch("app.bot.sync_with_google_sheets"):
with patch("app.bot.init_db"), patch("app.bot.Application.builder"), \
patch("app.bot.run_notifiers"), \
patch("app.bot.Thread") as mock_thread, \
patch("app.bot.sync_with_google_sheets"):

main()

# Ensure the thread for running notifiers is started
mock_thread.assert_called()
assert mock_thread.return_value.start.called, "Notifier thread should start"
assert mock_thread.return_value.start.called, \
"Notifier thread should start"

0 comments on commit b3489ab

Please sign in to comment.