python-telegram-bot/tests/base.py
2015-12-21 21:18:53 +01:00

55 lines
1.6 KiB
Python

#!/usr/bin/env python
#
# A library that provides a Python interface to the Telegram Bot API
# Copyright (C) 2015 Leandro Toledo de Souza <devs@python-telegram-bot.org>
#
# 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