mirror of
https://github.com/python-telegram-bot/python-telegram-bot.git
synced 2024-12-29 15:49:02 +01:00
Update Base tests class
This commit is contained in:
parent
4be946d116
commit
1b0c3731de
1 changed files with 55 additions and 0 deletions
55
tests/base.py
Normal file
55
tests/base.py
Normal file
|
@ -0,0 +1,55 @@
|
|||
#!/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 General 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 General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see [http://www.gnu.org/licenses/].
|
||||
|
||||
"""This module contains a object that represents a Base class for tests"""
|
||||
|
||||
import os
|
||||
import sys
|
||||
sys.path.append('.')
|
||||
|
||||
import json
|
||||
import telegram
|
||||
|
||||
|
||||
class BaseTest(object):
|
||||
"""This object represents a Base test and its sets of functions."""
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
super(BaseTest, self).__init__(*args, **kwargs)
|
||||
|
||||
bot = telegram.Bot(os.environ.get('TOKEN'))
|
||||
chat_id = os.environ.get('CHAT_ID')
|
||||
|
||||
self._bot = bot
|
||||
self._chat_id = chat_id
|
||||
|
||||
@staticmethod
|
||||
def is_json(string):
|
||||
try:
|
||||
json.loads(string)
|
||||
except ValueError:
|
||||
return False
|
||||
|
||||
return True
|
||||
|
||||
@staticmethod
|
||||
def is_dict(dictionary):
|
||||
if isinstance(dictionary, dict):
|
||||
return True
|
||||
|
||||
return False
|
Loading…
Reference in a new issue