Fix tests and minor changes

This commit is contained in:
Leandro Toledo 2015-08-28 13:02:02 -03:00
parent b20f5af1e1
commit 0f924508f7
10 changed files with 18 additions and 41 deletions

View file

@ -4,9 +4,10 @@ python:
- "2.7"
- "3.3"
- "3.4"
- "nightly"
install:
- pip install coveralls
script:
coverage run telegram_test.py
coverage run make test
after_success:
coveralls

View file

@ -1,7 +1,4 @@
help:
@echo " clean remove unwanted stuff"
@echo " lint check style with flake8"
@echo " test run tests"
.PHONY: clean test lint help
clean:
rm -fr build
@ -14,4 +11,9 @@ lint:
flake8 --doctests --max-complexity 10 telegram
test:
python telegram_test.py
@- $(foreach TEST, $(wildcard tests/test_*.py), python $(TEST))
help:
@echo " clean remove unwanted stuff"
@echo " lint check style with flake8"
@echo " test run tests"

View file

@ -1,30 +0,0 @@
#!/usr/bin/env python
#
# A library that provides a Python interface to the Telegram Bot API
# Copyright (C) 2015 Leandro Toledo de Souza <leandrotoeldodesouza@gmail.com>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Lesser Public License for more details.
#
# You should have received a copy of the GNU Lesser Public License
# along with this program. If not, see [http://www.gnu.org/licenses/].
import logging
import unittest
from tests.test_bot import BotTest
if __name__ == '__main__':
logging.basicConfig(
format='%(asctime)s - %(name)s - %(levelname)s - %(message)s')
logger = logging.getLogger()
logger.setLevel(logging.DEBUG)
testsuite = unittest.TestLoader().loadTestsFromTestCase(BotTest)
unittest.TextTestRunner(verbosity=1).run(testsuite)

View file

Before

Width:  |  Height:  |  Size: 13 KiB

After

Width:  |  Height:  |  Size: 13 KiB

View file

@ -19,6 +19,8 @@
import os
import sys
sys.path.append('.')
import json
import telegram
import unittest
@ -80,7 +82,7 @@ class BotTest(unittest.TestCase):
def testSendPhoto(self):
'''Test the telegram.Bot sendPhoto method'''
print('Testing sendPhoto - File')
message = self._bot.sendPhoto(photo=open('tests/telegram.png', 'rb'),
message = self._bot.sendPhoto(photo=open('tests/data/telegram.png', 'rb'),
caption='testSendPhoto',
chat_id=12173560)
self.assertTrue(self.is_json(message.to_json()))
@ -122,7 +124,7 @@ class BotTest(unittest.TestCase):
def testSendAudio(self):
'''Test the telegram.Bot sendAudio method'''
print('Testing sendAudio - File')
message = self._bot.sendAudio(audio=open('tests/telegram.mp3', 'rb'),
message = self._bot.sendAudio(audio=open('tests/data/telegram.mp3', 'rb'),
chat_id=12173560,
performer='Leandro Toledo',
title='Teste')
@ -144,7 +146,7 @@ class BotTest(unittest.TestCase):
def testSendVoice(self):
'''Test the telegram.Bot sendVoice method'''
print('Testing sendVoice - File')
message = self._bot.sendVoice(voice=open('tests/telegram.ogg', 'rb'),
message = self._bot.sendVoice(voice=open('tests/data/telegram.ogg', 'rb'),
chat_id=12173560)
self.assertTrue(self.is_json(message.to_json()))
self.assertEqual(9199, message.voice.file_size)
@ -160,7 +162,7 @@ class BotTest(unittest.TestCase):
def testSendDocument(self):
'''Test the telegram.Bot sendDocument method'''
print('Testing sendDocument - File')
message = self._bot.sendDocument(document=open('tests/telegram.png', 'rb'),
message = self._bot.sendDocument(document=open('tests/data/telegram.png', 'rb'),
chat_id=12173560)
self.assertTrue(self.is_json(message.to_json()))
self.assertEqual(12948, message.document.file_size)
@ -184,7 +186,7 @@ class BotTest(unittest.TestCase):
def testSendVideo(self):
'''Test the telegram.Bot sendVideo method'''
print('Testing sendVideo - File')
message = self._bot.sendVideo(video=open('tests/telegram.mp4', 'rb'),
message = self._bot.sendVideo(video=open('tests/data/telegram.mp4', 'rb'),
caption='testSendVideo',
chat_id=12173560)
self.assertTrue(self.is_json(message.to_json()))
@ -229,3 +231,5 @@ class BotTest(unittest.TestCase):
upf = self._bot.getUserProfilePhotos(user_id=12173560)
self.assertTrue(self.is_json(upf.to_json()))
self.assertEqual(6547, upf.photos[0][0].file_size)
unittest.main()