Skip to content
Merged
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,4 @@ script:

after_success:
- coverage combine
- codecov
- codecov -F Travis
27 changes: 20 additions & 7 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,29 @@ environment:
- PYTHON: "C:\\Python35"
- PYTHON: "C:\\Python36"

branches:
only:
- master

skip_branch_with_pr: true

max_jobs: 1

install:
# We need wheel installed to build wheels
- "SET PATH=%PYTHON%;%PYTHON%\\Scripts;%PATH%"
- "git submodule update --init --recursive"
- "%PYTHON%\\python.exe -m pip install -U wheel"
- "%PYTHON%\\python.exe -m pip install -r requirements.txt"
- "%PYTHON%\\python.exe -m pip install -r requirements-dev.txt"
# Check that we have the expected version and architecture for Python
- "python --version"
# We need wheel installed to build wheels
- "pip install -U codecov pytest-cov"
- "pip install -U wheel"
- "pip install -r requirements.txt"
- "pip install -r requirements-dev.txt"

build: off

cache: C:\Users\appveyor\pip\wheels

test_script:
- "%python%\\Scripts\\pytest -v --cov"
- "pytest -m \"not nocoverage\" --cov --cov-report xml:coverage.xml"

after_test:
- "codecov -f coverage.xml -F Appveyor"
16 changes: 13 additions & 3 deletions tests/test_bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#
# 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 os
import time
from datetime import datetime, timedelta
from platform import python_implementation
Expand All @@ -27,7 +28,7 @@
from telegram import (Bot, Update, ChatAction, TelegramError, User, InlineKeyboardMarkup,
InlineKeyboardButton, InlineQueryResultArticle, InputTextMessageContent,
ShippingOption, LabeledPrice)
from telegram.error import BadRequest, InvalidToken, NetworkError, RetryAfter, TimedOut
from telegram.error import BadRequest, InvalidToken, NetworkError, RetryAfter
from telegram.utils.helpers import from_timestamp

BASE_TIME = time.time()
Expand Down Expand Up @@ -148,6 +149,7 @@ def test_send_contact(self, bot, chat_id):
assert message.contact.first_name == first_name
assert message.contact.last_name == last_name

@pytest.mark.skipif(os.getenv('APPVEYOR'), reason='No game made for Appveyor bot (''yet)')
@flaky(3, 1)
@pytest.mark.timeout(10)
def test_send_game(self, bot, chat_id):
Expand Down Expand Up @@ -191,14 +193,16 @@ def test(_, url, data, *args, **kwargs):

@flaky(3, 1)
@pytest.mark.timeout(10)
def test_get_user_profile_photos(self, bot, chat_id):
def test_get_user_profile_photos(self, bot):
chat_id = 12173560 # hardcoded Leandro's chat_id
user_profile_photos = bot.get_user_profile_photos(chat_id)

assert user_profile_photos.photos[0][0].file_size == 12421

@flaky(3, 1)
@pytest.mark.timeout(10)
def test_get_one_user_profile_photo(self, bot, chat_id):
def test_get_one_user_profile_photo(self, bot):
chat_id = 12173560 # hardcoded Leandro's chat_id
user_profile_photos = bot.get_user_profile_photos(chat_id, offset=0, limit=1)
assert user_profile_photos.photos[0][0].file_size == 12421

Expand Down Expand Up @@ -364,6 +368,7 @@ def test_get_chat_member(self, bot, channel_id):
assert chat_member.status == 'administrator'
assert chat_member.user.username == 'EchteEldin'

@pytest.mark.skipif(os.getenv('APPVEYOR'), reason='No game made for Appveyor bot (yet)')
@flaky(3, 1)
@pytest.mark.timeout(10)
def test_set_game_score_1(self, bot, chat_id):
Expand All @@ -382,6 +387,7 @@ def test_set_game_score_1(self, bot, chat_id):
assert message.game.photo[0].file_size == game.game.photo[0].file_size
assert message.game.text != game.game.text

@pytest.mark.skipif(os.getenv('APPVEYOR'), reason='No game made for Appveyor bot (yet)')
@flaky(3, 1)
@pytest.mark.timeout(10)
def test_set_game_score_2(self, bot, chat_id):
Expand All @@ -403,6 +409,7 @@ def test_set_game_score_2(self, bot, chat_id):
assert message.game.photo[0].file_size == game.game.photo[0].file_size
assert message.game.text == game.game.text

@pytest.mark.skipif(os.getenv('APPVEYOR'), reason='No game made for Appveyor bot (yet)')
@flaky(3, 1)
@pytest.mark.timeout(10)
def test_set_game_score_3(self, bot, chat_id):
Expand All @@ -419,6 +426,7 @@ def test_set_game_score_3(self, bot, chat_id):
chat_id=game.chat_id,
message_id=game.message_id)

@pytest.mark.skipif(os.getenv('APPVEYOR'), reason='No game made for Appveyor bot (yet)')
@flaky(3, 1)
@pytest.mark.timeout(10)
def test_set_game_score_4(self, bot, chat_id):
Expand All @@ -444,6 +452,7 @@ def test_set_game_score_4(self, bot, chat_id):
game2 = bot.send_game(chat_id, game_short_name)
assert str(score) in game2.game.text

@pytest.mark.skipif(os.getenv('APPVEYOR'), reason='No game made for Appveyor bot (yet)')
@flaky(3, 1)
@pytest.mark.timeout(10)
def test_set_game_score_too_low_score(self, bot, chat_id):
Expand All @@ -455,6 +464,7 @@ def test_set_game_score_too_low_score(self, bot, chat_id):
bot.set_game_score(user_id=chat_id, score=100,
chat_id=game.chat_id, message_id=game.message_id)

@pytest.mark.skipif(os.getenv('APPVEYOR'), reason='No game made for Appveyor bot (yet)')
@flaky(3, 1)
@pytest.mark.timeout(10)
def test_get_game_high_scores(self, bot, chat_id):
Expand Down
2 changes: 2 additions & 0 deletions tests/test_jobqueue.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
# 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 datetime
import os
import time
from time import sleep

Expand All @@ -34,6 +35,7 @@ def job_queue(bot):
jq.stop()


@pytest.mark.skipif(os.getenv('APPVEYOR'), reason="On Appveyor precise timings are not accurate.")
@flaky(10, 1) # Timings aren't quite perfect
class TestJobQueue(object):
result = 0
Expand Down
4 changes: 4 additions & 0 deletions tests/test_messagequeue.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,15 @@
# 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 os
from time import sleep

import pytest

import telegram.ext.messagequeue as mq


@pytest.mark.skipif(os.getenv('APPVEYOR'), reason="On Appveyor precise timings are not accurate.")
class TestDelayQueue(object):
N = 128
burst_limit = 30
Expand Down
2 changes: 1 addition & 1 deletion tests/test_meta.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def call_pre_commit_hook(hook_id):

@pytest.mark.nocoverage
@pytest.mark.parametrize('hook_id', argvalues=('yapf', 'flake8', 'pylint'))
@pytest.mark.skipif(not os.getenv('TRAVIS'), reason='Not running in travis.')
@pytest.mark.skipif(not (os.getenv('TRAVIS') or os.getenv('APPVEYOR')), reason='Not running in CI')
@pytest.mark.skipif(not sys.version_info[:2] == (3, 6) or python_implementation() != 'CPython',
reason='Only running pre-commit-hooks on newest tested python version, '
'as they are slow and consistent across platforms.')
Expand Down
4 changes: 3 additions & 1 deletion tests/test_official.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,9 @@
import telegram

IGNORED_OBJECTS = ('ResponseParameters', 'CallbackGame')
IGNORED_PARAMETERS = {'self', 'args', 'kwargs', 'read_latency', 'network_delay', 'timeout', 'bot'}
IGNORED_PARAMETERS = {'self', 'args', 'kwargs', 'read_latency', 'network_delay', 'timeout', 'bot',
'new_chat_member'}
# TODO: New_chat_member is still in our lib but already removed from TG's docs.


def find_next_sibling_until(tag, name, until):
Expand Down
9 changes: 6 additions & 3 deletions tests/test_sticker.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
from future.utils import PY2

from telegram import Sticker, PhotoSize, TelegramError, StickerSet, Audio, MaskPosition
from telegram.error import BadRequest


@pytest.fixture(scope='function')
Expand Down Expand Up @@ -244,6 +243,7 @@ def test_de_json(self, bot):
assert sticker_set.contains_masks == self.contains_masks
assert sticker_set.stickers == self.stickers

@pytest.mark.skipif(os.getenv('APPVEYOR'), reason='No Sticker(set) for Appveyor bot (''yet)')
def test_sticker_set_to_dict(self, sticker_set):
sticker_set_dict = sticker_set.to_dict()

Expand All @@ -253,20 +253,23 @@ def test_sticker_set_to_dict(self, sticker_set):
assert sticker_set_dict['contains_masks'] == sticker_set.contains_masks
assert sticker_set_dict['stickers'][0] == sticker_set.stickers[0].to_dict()

@flaky(3,1)
@pytest.mark.skipif(os.getenv('APPVEYOR'), reason='No Sticker(set) for Appveyor bot (''yet)')
@flaky(3, 1)
@pytest.mark.timeout(10)
def test_bot_methods_1(self, bot, sticker_set):
with open('tests/data/telegram_sticker.png', 'rb') as f:
file = bot.upload_sticker_file(95205500, f)
assert file
assert bot.add_sticker_to_set(95205500, sticker_set.name, file.file_id, '😄')

@flaky(3,1)
@pytest.mark.skipif(os.getenv('APPVEYOR'), reason='No Sticker(set) for Appveyor bot (''yet)')
@flaky(3, 1)
@pytest.mark.timeout(10)
def test_bot_methods_2(self, bot, sticker_set):
file_id = sticker_set.stickers[0].file_id
assert bot.set_sticker_position_in_set(file_id, 1)

@pytest.mark.skipif(os.getenv('APPVEYOR'), reason='No Sticker(set) for Appveyor bot (''yet)')
@flaky(10, 1)
@pytest.mark.timeout(10)
def test_bot_methods_3(self, bot, sticker_set):
Expand Down