Fix bot instance passing in Dispatcher startup

Modified the Dispatcher to remove the "bot" key from workflow_data if found, prior to emitting startup in order to allow manual addition of "bot" to workflow data. This change was necessary as a bot instance is required to start polling, and therefore must be passed correctly. This logic is now tested in the 'test_start_polling' function. The change also includes an update to the changelog.
This commit is contained in:
Alex Root Junior 2023-08-06 00:48:39 +03:00
parent 90654ac0fa
commit cec2ac7358
No known key found for this signature in database
GPG key ID: 074C1D455EBEA4AC
3 changed files with 7 additions and 0 deletions

View file

@ -675,6 +675,7 @@ class TestDispatcher:
async def test_start_polling(self, bot: MockedBot):
dispatcher = Dispatcher()
dispatcher.workflow_data["bot"] = 42
with pytest.raises(
ValueError, match="At least one bot instance is required to start polling"
):
@ -708,6 +709,8 @@ class TestDispatcher:
mocked_emit_startup.assert_awaited()
mocked_process_update.assert_awaited()
mocked_emit_shutdown.assert_awaited()
assert dispatcher.workflow_data["bot"] == 42
assert mocked_emit_shutdown.call_args.kwargs["bot"] == bot
async def test_stop_polling(self):
dispatcher = Dispatcher()