def test_class_non_error_in_brackets_behaviour(self): # do a basic setup Bot.sendMessage = _fakeSendMessage_with429Error_unknown try: etlgrBot = EtlgrBot(token=BOT_TOKEN) etlgrSendResult = etlgrBot.sendMessage(self) except NetworkError as e: assert e.message == 'Too Many Requests: retry after 666'
def test_class_with_base_exception_behaviour(self): # do a basic setup Bot.sendMessage = _fakeSendMessage_with_base_exception etlgrBot = EtlgrBot(token=BOT_TOKEN) try: etlgrBot.sendMessage(self, None, None) except BaseException as e: assert e.message == "im a base exception"
def test_class_429_behaviour(self): global CURRENT_TIME CURRENT_TIME = 0 # do a 429 error setup Bot.sendMessage = _fakeSendMessage_with429Error etlgrBot = EtlgrBot(token=BOT_TOKEN) res = etlgrBot.sendMessage(self) assert res == "SUCCESS"
def test_class_429_deep_behaviour(self): global CURRENT_TIME CURRENT_TIME = 0 # do a 429 error setup Bot.sendDocument = _fakesendDocument_with429Error_deep time.sleep = fakeSleep etlgrBot = EtlgrBot(token=BOT_TOKEN) res = etlgrBot.sendDocument(self) assert res == "SUCCESS_DEEP"
def test_class_with_500_exception_behaviour(self): # do a basic setup Bot.sendMessage = _fakeSendMessage_with500Error etlgrBot = EtlgrBot(token=BOT_TOKEN) try: etlgrBot.sendMessage(self, None, None) except NetworkError as e: assert e.message == "Internal Server Error (500)" else: assert "This code should not be executed" == "exactly"
def test_class_ordinary_behaviour(self): # do a basic setup Bot.sendMessage = _fakeSendMessage # bot = Bot(token=BOT_TOKEN) originalResult = bot.sendMessage(self) etlgrBot = EtlgrBot(token=BOT_TOKEN) etlgrSendResult = etlgrBot.sendMessage(self) assert originalResult == etlgrSendResult
def test_class_429_deep_stack_overflow_behaviour(self): global CURRENT_TIME CURRENT_TIME = 0 # do a 429 error setup Bot.sendMessage = _fakeSendMessage_with429Error_deep_stack_overflow time.sleep = fakeSleep etlgrBot = EtlgrBot(token=BOT_TOKEN) try: etlgrBot.sendMessage(self) except NetworkError as e: assert e.message == "Too Many Requests: retry after 1 (429)"
def test_class_params_passing_behaviour(self): # do a basic setup Bot.sendDocument = _fakesendDocumentReturnParams # bot = Bot(token=BOT_TOKEN) originalResult1, originalResult2 = bot.sendDocument(self, 1, 2, 3, key1='val1', key2='val2') etlgrBot = EtlgrBot(token=BOT_TOKEN) etlgrSendResult1, etlgrSendResult2 = etlgrBot.sendDocument(self, 1, 2, 3, key1='val1', key2='val2') assert originalResult1 == etlgrSendResult1 assert originalResult2.get('key1') == etlgrSendResult2.get('key1') assert originalResult2.get('key2') == etlgrSendResult2.get('key2')