diff --git a/.travis.yml b/.travis.yml index f2630b00c..36fd6dd52 100644 --- a/.travis.yml +++ b/.travis.yml @@ -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 diff --git a/CHANGES b/CHANGES.rst similarity index 100% rename from CHANGES rename to CHANGES.rst diff --git a/Makefile b/Makefile index ec8ec3b62..6ebba9d0b 100644 --- a/Makefile +++ b/Makefile @@ -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" diff --git a/docs-requirements.txt b/docs/docs-requirements.txt similarity index 100% rename from docs-requirements.txt rename to docs/docs-requirements.txt diff --git a/telegram_test.py b/telegram_test.py deleted file mode 100644 index 488b915a7..000000000 --- a/telegram_test.py +++ /dev/null @@ -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 -# -# 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) diff --git a/tests/telegram.mp3 b/tests/data/telegram.mp3 similarity index 100% rename from tests/telegram.mp3 rename to tests/data/telegram.mp3 diff --git a/tests/telegram.mp4 b/tests/data/telegram.mp4 similarity index 100% rename from tests/telegram.mp4 rename to tests/data/telegram.mp4 diff --git a/tests/telegram.ogg b/tests/data/telegram.ogg similarity index 100% rename from tests/telegram.ogg rename to tests/data/telegram.ogg diff --git a/tests/telegram.png b/tests/data/telegram.png similarity index 100% rename from tests/telegram.png rename to tests/data/telegram.png diff --git a/tests/test_bot.py b/tests/test_bot.py index fcc266ea3..54ab4f61e 100644 --- a/tests/test_bot.py +++ b/tests/test_bot.py @@ -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()