class TestBot(BaseCase): def setUp(self): super().setUp() self.hCaptchaBot = HCaptchaBot(app_config["testing"].TELEGRAM_TOKEN) self.bot = self.hCaptchaBot.bot self.bot.get_me = MagicMock(return_value={ "is_bot": True, "username": "******" }) def test_is_bot(self): self.assertTrue(self.bot.get_me()["is_bot"]) def test_username(self): self.assertEqual(self.bot.get_me()["username"], app_config["testing"].TELEGRAM_USERNAME) def test_run(self): self.hCaptchaBot.handlers_manager.register = MagicMock( return_value=None) self.hCaptchaBot.updater.start_polling = MagicMock(return_value=None) self.hCaptchaBot.run() self.hCaptchaBot.handlers_manager.register.assert_called() self.hCaptchaBot.updater.start_polling.assert_called()
def setUp(self): super().setUp() self.hCaptchaBot = HCaptchaBot(app_config["testing"].TELEGRAM_TOKEN) self.bot = self.hCaptchaBot.bot self.bot.get_me = MagicMock(return_value={ "is_bot": True, "username": "******" })
def setUp(self): super().setUp() self.command = BaseHandler(self.app) hcaptcha_bot = HCaptchaBot(app_config["testing"].TELEGRAM_TOKEN) self.app.bot_instance = hcaptcha_bot self.bot = hcaptcha_bot.bot self.worker = hcaptcha_bot.worker
def register_bot(app, config_name): app.bot_instance = HCaptchaBot(get_active_config().TELEGRAM_TOKEN, app) # Don't explicitly run the bot in testing env if config_name != "testing": app.bot_instance.setup() app.bot_instance.run()
def setUp(self): super().setUp() self.test_bot = HCaptchaBot(app_config["testing"].TELEGRAM_TOKEN).bot self.test_app = create_app("testing") # hours will leads to delete all messages when running the worker self.test_worker = CleanupWorker(self.test_bot, self.test_app, minutes=0)
def setUp(self): super().setUp() self.command = BaseHandler(self.app) hcaptcha_bot = HCaptchaBot(app_config["testing"].TELEGRAM_TOKEN) self.app.bot_instance = hcaptcha_bot self.bot = hcaptcha_bot.bot self.worker = hcaptcha_bot.worker self.bot.bot = MagicMock(return_value=AttrDict({"id": 123})) self.bot.get_my_commands = MagicMock(return_value=None) self.bot.get_me = MagicMock(return_value={ "is_bot": True, "username": "******" })
def setUp(self): super().setUp() self.hCaptchaBot = HCaptchaBot(app_config["testing"].TELEGRAM_TOKEN) self.bot = self.hCaptchaBot.bot
def setUp(self): super().setUp() self.hCaptchaBot = HCaptchaBot(get_active_config().TELEGRAM_TOKEN) self.bot = self.hCaptchaBot.bot