Skip to content

Commit b494319

Browse files
committed
Reworked get_bot
It now decides wich bot to give depending on CI, and made ready or more bot's per version.
1 parent fca64f5 commit b494319

File tree

1 file changed

+42
-12
lines changed

1 file changed

+42
-12
lines changed

tests/bots.py

Lines changed: 42 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -17,20 +17,50 @@
1717
# You should have received a copy of the GNU General Public License
1818
# along with this program. If not, see [http://www.gnu.org/licenses/].
1919
"""Provide a bot to tests"""
20+
import os
2021

21-
import telegram
22+
import sys
2223

23-
bots = [
24-
{
25-
'token': '133505823:AAHZFMHno3mzVLErU5b5jJvaeG--qUyLyG0',
26-
'chat_id': '12173560',
27-
'group_id': '-49740850',
28-
'channel_id': '@pythontelegrambottests',
29-
'payment_provider_token': '284685063:TEST:ZGJlMmQxZDI3ZTc3',
30-
'user': telegram.User(133505823, 'PythonTelegramBot', username='PythonTelegramBot')
31-
}
32-
]
24+
25+
bot_settings = {
26+
'APPVEYOR':
27+
{
28+
'token': '133505823:AAHZFMHno3mzVLErU5b5jJvaeG--qUyLyG0',
29+
'payment_provider_token': '284685063:TEST:ZGJlMmQxZDI3ZTc3'
30+
},
31+
'TRAVIS':
32+
{
33+
'token': '133505823:AAHZFMHno3mzVLErU5b5jJvaeG--qUyLyG0',
34+
'payment_provider_token': '284685063:TEST:ZGJlMmQxZDI3ZTc3'
35+
},
36+
'FALLBACK':
37+
{
38+
'token': '133505823:AAHZFMHno3mzVLErU5b5jJvaeG--qUyLyG0',
39+
'payment_provider_token': '284685063:TEST:ZGJlMmQxZDI3ZTc3'
40+
}
41+
}
3342

3443

3544
def get_bot():
36-
return bots[0]
45+
# TODO: Add version info with different bots
46+
# ver = sys.version_info
47+
# pyver = "{}{}".format(ver[0], ver[1])
48+
#
49+
bot = None
50+
if os.environ.get('TRAVIS', False):
51+
bot = bot_settings.get('TRAVIS', None)
52+
# TODO:
53+
# bot = bot_setting.get('TRAVIS'+pyver, None)
54+
elif os.environ.get('APPVEYOR', False):
55+
bot = bot_settings.get('APPVEYOR', None)
56+
# TODO:
57+
# bot = bot_setting.get('TRAVIS'+pyver, None)
58+
if not bot:
59+
bot = bot_settings['FALLBACK']
60+
61+
bot.update({
62+
'chat_id': '12173560',
63+
'group_id': '-49740850',
64+
'channel_id': '@pythontelegrambottests'
65+
})
66+
return bot

0 commit comments

Comments
 (0)