12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849 |
- import unittest.mock
- from location_guessing_game_telegram_bot import _run
- def test__run(tmp_path, wikimap_export_path):
- telegram_token_path = tmp_path.joinpath("token")
- telegram_token_path.write_text("secret\n")
- with unittest.mock.patch("telegram.ext.Updater") as updater_mock:
- _run(
- telegram_token_path=telegram_token_path,
- wikimap_export_path=wikimap_export_path,
- )
- updater_mock.assert_called_once()
-
-
- init_args, init_kwargs = updater_mock.call_args
- assert not init_args
- assert set(init_kwargs.keys()) == {
- "persistence",
- "token",
- "use_context",
- }
- assert init_kwargs["token"] == "secret"
- assert init_kwargs["use_context"] is True
- photos = init_kwargs["persistence"].get_bot_data()["photos"]
- assert len(photos) == 25
- assert (
- photos[1].photo_url
- == "https://upload.wikimedia.org/wikipedia/commons/6/65/Gro%C3%9Fvenediger3.JPG"
- )
|