AIOG-T-51. TelegramObject property bot added

* property added
 * unit tests added
 * local import used to avoid circular reference
This commit is contained in:
Igor Sereda 2020-05-31 03:37:00 +03:00
parent 53db44101f
commit b6ff48d8fc
2 changed files with 40 additions and 0 deletions

View file

@ -0,0 +1,21 @@
import pytest
from aiogram import Bot
from aiogram.api.types import TelegramObject
class TestTelegramObject:
@pytest.fixture()
def context_cleanup(self):
yield
Bot.reset_current(self.__token)
@pytest.mark.usefixtures("context_cleanup")
def test_bot_property_positive(self):
self.__token = Bot.set_current(Bot("42:TEST"))
assert isinstance(TelegramObject().bot, Bot)
def test_bot_property_negative(self):
with pytest.raises(RuntimeError, match=r"Bot.set_current\(bot_instance\)"):
isinstance(TelegramObject().bot, Bot)