From 1b0c3731de10e207e4be095ab883859531960a19 Mon Sep 17 00:00:00 2001 From: leandrotoledo Date: Mon, 7 Sep 2015 14:12:58 -0300 Subject: [PATCH] Update Base tests class --- tests/base.py | 55 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 tests/base.py diff --git a/tests/base.py b/tests/base.py new file mode 100644 index 000000000..8dfeccb57 --- /dev/null +++ b/tests/base.py @@ -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 +# +# 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