mirror of
https://github.com/python-telegram-bot/python-telegram-bot.git
synced 2025-01-16 14:33:12 +01:00
Move photo tests from test_bot to test_photo
This commit is contained in:
parent
c92ebc4046
commit
fca64f5fc6
2 changed files with 47 additions and 73 deletions
|
@ -121,78 +121,6 @@ class BotTest(BaseTest, unittest.TestCase):
|
|||
self.assertEqual(message.forward_from.username, 'leandrotoledo')
|
||||
self.assertTrue(isinstance(message.forward_date, datetime))
|
||||
|
||||
@flaky(3, 1)
|
||||
@timeout(10)
|
||||
def testSendPhoto(self):
|
||||
message = self._bot.sendPhoto(
|
||||
photo=open('tests/data/telegram.png', 'rb'),
|
||||
caption='testSendPhoto',
|
||||
chat_id=self._chat_id)
|
||||
|
||||
self.assertTrue(self.is_json(message.to_json()))
|
||||
self.assertEqual(message.photo[0].file_size, 1451)
|
||||
self.assertEqual(message.caption, 'testSendPhoto')
|
||||
|
||||
@flaky(3, 1)
|
||||
@timeout(10)
|
||||
def testSilentSendPhoto(self):
|
||||
message = self._bot.sendPhoto(
|
||||
photo=open('tests/data/telegram.png', 'rb'),
|
||||
caption='testSendPhoto',
|
||||
chat_id=self._chat_id,
|
||||
disable_notification=True)
|
||||
|
||||
self.assertTrue(self.is_json(message.to_json()))
|
||||
self.assertEqual(message.photo[0].file_size, 1451)
|
||||
self.assertEqual(message.caption, 'testSendPhoto')
|
||||
|
||||
@flaky(3, 1)
|
||||
@timeout(10)
|
||||
def testResendPhoto(self):
|
||||
message = self._bot.sendPhoto(
|
||||
photo='AgADAQAD1y0yGx8j9Qf8f_m3CKeS6Iy95y8ABI1ggfVJ4-UvwJcAAgI', chat_id=self._chat_id)
|
||||
|
||||
self.assertTrue(self.is_json(message.to_json()))
|
||||
self.assertEqual(message.photo[0].file_id,
|
||||
'AgADAQAD1y0yGx8j9Qf8f_m3CKeS6Iy95y8ABI1ggfVJ4-UvwJcAAgI')
|
||||
|
||||
@flaky(3, 1)
|
||||
@timeout(10)
|
||||
def testSendJPGURLPhoto(self):
|
||||
message = self._bot.sendPhoto(
|
||||
photo='http://dummyimage.com/600x400/000/fff.jpg&text=telegram', chat_id=self._chat_id)
|
||||
|
||||
self.assertTrue(self.is_json(message.to_json()))
|
||||
self.assertEqual(message.photo[0].file_size, 813)
|
||||
|
||||
@flaky(3, 1)
|
||||
@timeout(10)
|
||||
def testSendPNGURLPhoto(self):
|
||||
message = self._bot.sendPhoto(
|
||||
photo='http://dummyimage.com/600x400/000/fff.png&text=telegram', chat_id=self._chat_id)
|
||||
|
||||
self.assertTrue(self.is_json(message.to_json()))
|
||||
self.assertEqual(message.photo[0].file_size, 670)
|
||||
|
||||
@flaky(3, 1)
|
||||
@timeout(10)
|
||||
def testSendGIFURLPhoto(self):
|
||||
message = self._bot.sendPhoto(
|
||||
photo='http://dummyimage.com/600x400/000/fff.gif&text=telegram', chat_id=self._chat_id)
|
||||
|
||||
self.assertTrue(self.is_json(message.to_json()))
|
||||
self.assertEqual(message.photo[0].file_size, 670)
|
||||
|
||||
@flaky(3, 1)
|
||||
@timeout(10)
|
||||
def testSendBufferedReaderPhoto(self):
|
||||
photo = open('tests/data/telegram.png', 'rb')
|
||||
br_photo = io.BufferedReader(io.BytesIO(photo.read()))
|
||||
message = self._bot.sendPhoto(photo=br_photo, chat_id=self._chat_id)
|
||||
|
||||
self.assertTrue(self.is_json(message.to_json()))
|
||||
self.assertEqual(message.photo[0].file_size, 1451)
|
||||
|
||||
@flaky(3, 1)
|
||||
@timeout(10)
|
||||
def testSendGame(self):
|
||||
|
|
|
@ -74,7 +74,7 @@ class PhotoTest(BaseTest, unittest.TestCase):
|
|||
|
||||
@flaky(3, 1)
|
||||
@timeout(10)
|
||||
def test_sendphotoo_all_args(self):
|
||||
def test_sendphoto_all_args(self):
|
||||
message = self._bot.sendPhoto(self._chat_id, self.photo_file, caption=self.caption, disable_notification=False)
|
||||
thumb, photo = message.photo
|
||||
|
||||
|
@ -115,6 +115,38 @@ class PhotoTest(BaseTest, unittest.TestCase):
|
|||
self.assertEqual(photo.height, self.photo.height)
|
||||
self.assertEqual(photo.file_size, self.photo.file_size)
|
||||
|
||||
@flaky(3, 1)
|
||||
@timeout(10)
|
||||
def test_send_photo_url_png_file(self):
|
||||
message = self._bot.sendPhoto(
|
||||
photo='http://dummyimage.com/600x400/000/fff.png&text=telegram', chat_id=self._chat_id)
|
||||
|
||||
thumb, photo = message.photo
|
||||
|
||||
self.assertIsInstance(thumb, telegram.PhotoSize)
|
||||
self.assertIsInstance(thumb.file_id, str)
|
||||
self.assertNotEqual(thumb.file_id, '')
|
||||
|
||||
self.assertIsInstance(photo, telegram.PhotoSize)
|
||||
self.assertIsInstance(photo.file_id, str)
|
||||
self.assertNotEqual(photo.file_id, '')
|
||||
|
||||
@flaky(3, 1)
|
||||
@timeout(10)
|
||||
def test_send_photo_url_gif_file(self):
|
||||
message = self._bot.sendPhoto(
|
||||
photo='http://dummyimage.com/600x400/000/fff.gif&text=telegram', chat_id=self._chat_id)
|
||||
|
||||
thumb, photo = message.photo
|
||||
|
||||
self.assertIsInstance(thumb, telegram.PhotoSize)
|
||||
self.assertIsInstance(thumb.file_id, str)
|
||||
self.assertNotEqual(thumb.file_id, '')
|
||||
|
||||
self.assertIsInstance(photo, telegram.PhotoSize)
|
||||
self.assertIsInstance(photo.file_id, str)
|
||||
self.assertNotEqual(photo.file_id, '')
|
||||
|
||||
@flaky(3, 1)
|
||||
@timeout(10)
|
||||
def test_send_photo_bytesio_jpg_file(self):
|
||||
|
@ -141,6 +173,20 @@ class PhotoTest(BaseTest, unittest.TestCase):
|
|||
self.assertEqual(photo.height, 1080)
|
||||
self.assertEqual(photo.file_size, 30907)
|
||||
|
||||
@flaky(3, 1)
|
||||
@timeout(10)
|
||||
def test_silent_send_photo(self):
|
||||
message = self._bot.sendPhoto(photo=self.photo_file, chat_id=self._chat_id, disable_notification=True)
|
||||
thumb, photo = message.photo
|
||||
|
||||
self.assertIsInstance(thumb, telegram.PhotoSize)
|
||||
self.assertIsInstance(thumb.file_id, str)
|
||||
self.assertNotEqual(thumb.file_id, '')
|
||||
|
||||
self.assertIsInstance(photo, telegram.PhotoSize)
|
||||
self.assertIsInstance(photo.file_id, str)
|
||||
self.assertNotEqual(photo.file_id, '')
|
||||
|
||||
@flaky(3, 1)
|
||||
@timeout(10)
|
||||
def test_send_photo_resend(self):
|
||||
|
|
Loading…
Reference in a new issue