Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adapting code to python-telegram-bot 8.1.1 #17

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion ptbtest/mockbot.py
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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