def test_init(self): """Test initialization parameters""" client = TelegramBotClient(TELEGRAM_TOKEN) self.assertEqual(client.bot_token, TELEGRAM_TOKEN) self.assertTrue(client.ssl_verify) client = TelegramBotClient(TELEGRAM_TOKEN, ssl_verify=False) self.assertEqual(client.bot_token, TELEGRAM_TOKEN) self.assertFalse(client.ssl_verify)
def test_updates(self): """Test updates API call""" setup_http_server() client = TelegramBotClient(TELEGRAM_TOKEN) # Check empty params client.updates() expected = {} req = httpretty.last_request() self.assertEqual(req.method, 'GET') self.assertRegex(req.path, '/bot12345678/getUpdates') self.assertDictEqual(req.querystring, expected) # Check request with offset client.updates(offset=319280321) expected = {'offset': ['319280321']} req = httpretty.last_request() self.assertEqual(req.method, 'GET') self.assertRegex(req.path, '/bot12345678/getUpdates') self.assertDictEqual(req.querystring, expected)
def test_sanitize_for_archive(self): """Test whether the sanitize method works properly""" url = "https://api.telegram.org/bot12345678/getUpdates" headers = "headers-information" payload = "payload-information" s_url, s_headers, s_payload = TelegramBotClient.sanitize_for_archive( url, headers, payload) self.assertEqual(s_url, "https://api.telegram.org/botXXXXX/getUpdates") self.assertEqual(s_headers, headers) self.assertEqual(s_payload, payload)
def test_init(self): """Test initialization parameters""" client = TelegramBotClient(TELEGRAM_TOKEN) self.assertEqual(client.bot_token, TELEGRAM_TOKEN)