Skip to content

Commit

Permalink
Merge 652150e into 8d5fee3
Browse files Browse the repository at this point in the history
  • Loading branch information
Lucas Peres committed Nov 8, 2017
2 parents 8d5fee3 + 652150e commit 0628636
Show file tree
Hide file tree
Showing 8 changed files with 22 additions and 3 deletions.
4 changes: 3 additions & 1 deletion ptbtest/mockbot.py
Expand Up @@ -27,6 +27,7 @@
import time

from telegram import (User, ReplyMarkup, TelegramObject)
from telegram.utils.request import Request
from telegram.error import TelegramError

logging.getLogger(__name__).addHandler(logging.NullHandler())
Expand Down Expand Up @@ -68,6 +69,7 @@ def __init__(self, username="MockBot", **kwargs):
from .chatgenerator import ChatGenerator
self.mg = MessageGenerator(bot=self)
self.cg = ChatGenerator()
self.request = Request()

@property
def sent_messages(self):
Expand Down Expand Up @@ -190,7 +192,7 @@ def decorator(self, *args, **kwargs):
return decorator

def getMe(self, timeout=None, **kwargs):
self.bot = User(0, "Mockbot", last_name="Bot", username=self._username)
self.bot = User(0, "Mockbot", last_name="Bot", is_bot=True, username=self._username)
return self.bot

@message
Expand Down
3 changes: 2 additions & 1 deletion ptbtest/usergenerator.py
Expand Up @@ -42,7 +42,7 @@ def __init__(self):
PtbGenerator.__init__(self)

def get_user(self, first_name=None, last_name=None, username=None,
id=None):
id=None, is_bot=False):
"""
Returns a telegram.User object with the optionally given name(s) or username
If any of the arguments are omitted the names will be chosen randomly and the
Expand All @@ -66,5 +66,6 @@ def get_user(self, first_name=None, last_name=None, username=None,
return User(
id or self.gen_id(),
first_name,
is_bot=is_bot,
last_name=last_name,
username=username)
3 changes: 3 additions & 0 deletions tests/test_Callbackquerygenerator.py
Expand Up @@ -19,6 +19,9 @@
# You should have received a copy of the GNU Lesser Public License
# along with this program. If not, see [http://www.gnu.org/licenses/].
from __future__ import absolute_import
from os import sys
sys.path.append("..")

import unittest

from ptbtest import (BadBotException, BadCallbackQueryException,
Expand Down
3 changes: 3 additions & 0 deletions tests/test_Chatgenerator.py
Expand Up @@ -19,6 +19,9 @@
# You should have received a copy of the GNU Lesser Public License
# along with this program. If not, see [http://www.gnu.org/licenses/].
from __future__ import absolute_import
from os import sys
sys.path.append("..")

import unittest
from ptbtest import ChatGenerator
from ptbtest import UserGenerator
Expand Down
3 changes: 3 additions & 0 deletions tests/test_Inlinequerygenerator.py
Expand Up @@ -19,6 +19,9 @@
# You should have received a copy of the GNU Lesser Public License
# along with this program. If not, see [http://www.gnu.org/licenses/].
from __future__ import absolute_import
from os import sys
sys.path.append("..")

import unittest

from ptbtest.errors import (BadBotException, BadUserException)
Expand Down
2 changes: 2 additions & 0 deletions tests/test_Messagegenerator.py
@@ -1,4 +1,6 @@
from __future__ import absolute_import
from os import sys
sys.path.append("..")

import unittest

Expand Down
4 changes: 3 additions & 1 deletion tests/test_Mockbot.py
Expand Up @@ -19,6 +19,8 @@
# You should have received a copy of the GNU Lesser Public License
# along with this program. If not, see [http://www.gnu.org/licenses/].
from __future__ import absolute_import
from os import sys
sys.path.append("..")

import unittest

Expand Down Expand Up @@ -47,7 +49,7 @@ def start(bot, update):
dp = updater.dispatcher
dp.add_handler(CommandHandler("start", start))
updater.start_polling()
user = User(id=1, first_name="test")
user = User(id=1, first_name="test", is_bot=False)
chat = Chat(45, "group")
message = Message(
404, user, None, chat, text="/start", bot=self.mockbot)
Expand Down
3 changes: 3 additions & 0 deletions tests/test_Usergenerator.py
Expand Up @@ -19,6 +19,9 @@
# You should have received a copy of the GNU Lesser Public License
# along with this program. If not, see [http://www.gnu.org/licenses/].
from __future__ import absolute_import
from os import sys
sys.path.append("..")

import unittest

from ptbtest import UserGenerator
Expand Down

0 comments on commit 0628636

Please sign in to comment.