mirror of
https://github.com/aiogram/aiogram.git
synced 2025-12-08 17:13:56 +00:00
Add Black and Flake8
This commit is contained in:
parent
5b9d82f1ca
commit
7c51b1a7d7
124 changed files with 5841 additions and 3772 deletions
|
|
@ -2,7 +2,7 @@ import aresponses
|
|||
|
||||
from aiogram import Bot
|
||||
|
||||
TOKEN = '123456789:AABBCCDDEEFFaabbccddeeff-1234567890'
|
||||
TOKEN = "123456789:AABBCCDDEEFFaabbccddeeff-1234567890"
|
||||
|
||||
|
||||
class FakeTelegram(aresponses.ResponsesMockServer):
|
||||
|
|
@ -15,11 +15,11 @@ class FakeTelegram(aresponses.ResponsesMockServer):
|
|||
|
||||
async def __aenter__(self):
|
||||
await super().__aenter__()
|
||||
_response = self.Response(text=self._body, headers=self._headers, status=200, reason='OK')
|
||||
_response = self.Response(text=self._body, headers=self._headers, status=200, reason="OK")
|
||||
self.add(self.ANY, response=_response)
|
||||
|
||||
async def __aexit__(self, exc_type, exc_val, exc_tb):
|
||||
if hasattr(self, 'monkeypatch'):
|
||||
if hasattr(self, "monkeypatch"):
|
||||
self.monkeypatch.undo()
|
||||
await super().__aexit__(exc_type, exc_val, exc_tb)
|
||||
|
||||
|
|
@ -27,14 +27,16 @@ class FakeTelegram(aresponses.ResponsesMockServer):
|
|||
def parse_data(message_dict):
|
||||
import json
|
||||
|
||||
_body = '{"ok":true,"result":' + json.dumps(message_dict) + '}'
|
||||
_headers = {'Server': 'nginx/1.12.2',
|
||||
'Date': 'Tue, 03 Apr 2018 16:59:54 GMT',
|
||||
'Content-Type': 'application/json',
|
||||
'Content-Length': str(len(_body)),
|
||||
'Connection': 'keep-alive',
|
||||
'Access-Control-Allow-Origin': '*',
|
||||
'Access-Control-Allow-Methods': 'GET, POST, OPTIONS',
|
||||
'Access-Control-Expose-Headers': 'Content-Length,Content-Type,Date,Server,Connection',
|
||||
'Strict-Transport-Security': 'max-age=31536000; includeSubdomains'}
|
||||
_body = '{"ok":true,"result":' + json.dumps(message_dict) + "}"
|
||||
_headers = {
|
||||
"Server": "nginx/1.12.2",
|
||||
"Date": "Tue, 03 Apr 2018 16:59:54 GMT",
|
||||
"Content-Type": "application/json",
|
||||
"Content-Length": str(len(_body)),
|
||||
"Connection": "keep-alive",
|
||||
"Access-Control-Allow-Origin": "*",
|
||||
"Access-Control-Allow-Methods": "GET, POST, OPTIONS",
|
||||
"Access-Control-Expose-Headers": "Content-Length,Content-Type,Date,Server,Connection",
|
||||
"Strict-Transport-Security": "max-age=31536000; includeSubdomains",
|
||||
}
|
||||
return _body, _headers
|
||||
|
|
|
|||
|
|
@ -13,15 +13,15 @@ class MyGroup(StatesGroup):
|
|||
sub_state_1 = State()
|
||||
sub_state_2 = State()
|
||||
|
||||
in_custom_group = State(group_name='custom_group')
|
||||
in_custom_group = State(group_name="custom_group")
|
||||
|
||||
class NewGroup(StatesGroup):
|
||||
spam = State()
|
||||
renamed_state = State(state='spam_state')
|
||||
renamed_state = State(state="spam_state")
|
||||
|
||||
|
||||
alone_state = State('alone')
|
||||
alone_in_group = State('alone', group_name='home')
|
||||
alone_state = State("alone")
|
||||
alone_in_group = State("alone", group_name="home")
|
||||
|
||||
|
||||
def test_default_state():
|
||||
|
|
@ -29,64 +29,76 @@ def test_default_state():
|
|||
|
||||
|
||||
def test_any_state():
|
||||
assert any_state.state == '*'
|
||||
assert any_state.state == "*"
|
||||
|
||||
|
||||
def test_alone_state():
|
||||
assert alone_state.state == '@:alone'
|
||||
assert alone_in_group.state == 'home:alone'
|
||||
assert alone_state.state == "@:alone"
|
||||
assert alone_in_group.state == "home:alone"
|
||||
|
||||
|
||||
def test_group_names():
|
||||
assert MyGroup.__group_name__ == 'MyGroup'
|
||||
assert MyGroup.__full_group_name__ == 'MyGroup'
|
||||
assert MyGroup.__group_name__ == "MyGroup"
|
||||
assert MyGroup.__full_group_name__ == "MyGroup"
|
||||
|
||||
assert MyGroup.MySubGroup.__group_name__ == 'MySubGroup'
|
||||
assert MyGroup.MySubGroup.__full_group_name__ == 'MyGroup.MySubGroup'
|
||||
assert MyGroup.MySubGroup.__group_name__ == "MySubGroup"
|
||||
assert MyGroup.MySubGroup.__full_group_name__ == "MyGroup.MySubGroup"
|
||||
|
||||
assert MyGroup.MySubGroup.NewGroup.__group_name__ == 'NewGroup'
|
||||
assert MyGroup.MySubGroup.NewGroup.__full_group_name__ == 'MyGroup.MySubGroup.NewGroup'
|
||||
assert MyGroup.MySubGroup.NewGroup.__group_name__ == "NewGroup"
|
||||
assert MyGroup.MySubGroup.NewGroup.__full_group_name__ == "MyGroup.MySubGroup.NewGroup"
|
||||
|
||||
|
||||
def test_custom_group_in_group():
|
||||
assert MyGroup.MySubGroup.in_custom_group.state == 'custom_group:in_custom_group'
|
||||
assert MyGroup.MySubGroup.in_custom_group.state == "custom_group:in_custom_group"
|
||||
|
||||
|
||||
def test_custom_state_name_in_group():
|
||||
assert MyGroup.MySubGroup.NewGroup.renamed_state.state == 'MyGroup.MySubGroup.NewGroup:spam_state'
|
||||
assert (
|
||||
MyGroup.MySubGroup.NewGroup.renamed_state.state == "MyGroup.MySubGroup.NewGroup:spam_state"
|
||||
)
|
||||
|
||||
|
||||
def test_group_states_names():
|
||||
assert len(MyGroup.states) == 3
|
||||
assert len(MyGroup.all_states) == 9
|
||||
|
||||
assert MyGroup.states_names == ('MyGroup:state', 'MyGroup:state_1', 'MyGroup:state_2')
|
||||
assert MyGroup.states_names == ("MyGroup:state", "MyGroup:state_1", "MyGroup:state_2")
|
||||
assert MyGroup.MySubGroup.states_names == (
|
||||
'MyGroup.MySubGroup:sub_state', 'MyGroup.MySubGroup:sub_state_1', 'MyGroup.MySubGroup:sub_state_2',
|
||||
'custom_group:in_custom_group')
|
||||
"MyGroup.MySubGroup:sub_state",
|
||||
"MyGroup.MySubGroup:sub_state_1",
|
||||
"MyGroup.MySubGroup:sub_state_2",
|
||||
"custom_group:in_custom_group",
|
||||
)
|
||||
assert MyGroup.MySubGroup.NewGroup.states_names == (
|
||||
'MyGroup.MySubGroup.NewGroup:spam', 'MyGroup.MySubGroup.NewGroup:spam_state')
|
||||
"MyGroup.MySubGroup.NewGroup:spam",
|
||||
"MyGroup.MySubGroup.NewGroup:spam_state",
|
||||
)
|
||||
|
||||
assert MyGroup.all_states_names == (
|
||||
'MyGroup:state', 'MyGroup:state_1', 'MyGroup:state_2',
|
||||
'MyGroup.MySubGroup:sub_state',
|
||||
'MyGroup.MySubGroup:sub_state_1',
|
||||
'MyGroup.MySubGroup:sub_state_2',
|
||||
'custom_group:in_custom_group',
|
||||
'MyGroup.MySubGroup.NewGroup:spam',
|
||||
'MyGroup.MySubGroup.NewGroup:spam_state')
|
||||
"MyGroup:state",
|
||||
"MyGroup:state_1",
|
||||
"MyGroup:state_2",
|
||||
"MyGroup.MySubGroup:sub_state",
|
||||
"MyGroup.MySubGroup:sub_state_1",
|
||||
"MyGroup.MySubGroup:sub_state_2",
|
||||
"custom_group:in_custom_group",
|
||||
"MyGroup.MySubGroup.NewGroup:spam",
|
||||
"MyGroup.MySubGroup.NewGroup:spam_state",
|
||||
)
|
||||
|
||||
assert MyGroup.MySubGroup.all_states_names == (
|
||||
'MyGroup.MySubGroup:sub_state',
|
||||
'MyGroup.MySubGroup:sub_state_1',
|
||||
'MyGroup.MySubGroup:sub_state_2',
|
||||
'custom_group:in_custom_group',
|
||||
'MyGroup.MySubGroup.NewGroup:spam',
|
||||
'MyGroup.MySubGroup.NewGroup:spam_state')
|
||||
"MyGroup.MySubGroup:sub_state",
|
||||
"MyGroup.MySubGroup:sub_state_1",
|
||||
"MyGroup.MySubGroup:sub_state_2",
|
||||
"custom_group:in_custom_group",
|
||||
"MyGroup.MySubGroup.NewGroup:spam",
|
||||
"MyGroup.MySubGroup.NewGroup:spam_state",
|
||||
)
|
||||
|
||||
assert MyGroup.MySubGroup.NewGroup.all_states_names == (
|
||||
'MyGroup.MySubGroup.NewGroup:spam',
|
||||
'MyGroup.MySubGroup.NewGroup:spam_state')
|
||||
"MyGroup.MySubGroup.NewGroup:spam",
|
||||
"MyGroup.MySubGroup.NewGroup:spam_state",
|
||||
)
|
||||
|
||||
|
||||
def test_root_element():
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ import pytest
|
|||
|
||||
from aiogram import Bot, types
|
||||
|
||||
TOKEN = '123456789:AABBCCDDEEFFaabbccddeeff-1234567890'
|
||||
TOKEN = "123456789:AABBCCDDEEFFaabbccddeeff-1234567890"
|
||||
|
||||
|
||||
class FakeTelegram(aresponses.ResponsesMockServer):
|
||||
|
|
@ -13,23 +13,25 @@ class FakeTelegram(aresponses.ResponsesMockServer):
|
|||
|
||||
async def __aenter__(self):
|
||||
await super().__aenter__()
|
||||
_response = self.Response(text=self._body, headers=self._headers, status=200, reason='OK')
|
||||
_response = self.Response(text=self._body, headers=self._headers, status=200, reason="OK")
|
||||
self.add(self.ANY, response=_response)
|
||||
|
||||
@staticmethod
|
||||
def parse_data(message_dict):
|
||||
import json
|
||||
|
||||
_body = '{"ok":true,"result":' + json.dumps(message_dict) + '}'
|
||||
_headers = {'Server': 'nginx/1.12.2',
|
||||
'Date': 'Tue, 03 Apr 2018 16:59:54 GMT',
|
||||
'Content-Type': 'application/json',
|
||||
'Content-Length': str(len(_body)),
|
||||
'Connection': 'keep-alive',
|
||||
'Access-Control-Allow-Origin': '*',
|
||||
'Access-Control-Allow-Methods': 'GET, POST, OPTIONS',
|
||||
'Access-Control-Expose-Headers': 'Content-Length,Content-Type,Date,Server,Connection',
|
||||
'Strict-Transport-Security': 'max-age=31536000; includeSubdomains'}
|
||||
_body = '{"ok":true,"result":' + json.dumps(message_dict) + "}"
|
||||
_headers = {
|
||||
"Server": "nginx/1.12.2",
|
||||
"Date": "Tue, 03 Apr 2018 16:59:54 GMT",
|
||||
"Content-Type": "application/json",
|
||||
"Content-Length": str(len(_body)),
|
||||
"Connection": "keep-alive",
|
||||
"Access-Control-Allow-Origin": "*",
|
||||
"Access-Control-Allow-Methods": "GET, POST, OPTIONS",
|
||||
"Access-Control-Expose-Headers": "Content-Length,Content-Type,Date,Server,Connection",
|
||||
"Strict-Transport-Security": "max-age=31536000; includeSubdomains",
|
||||
}
|
||||
return _body, _headers
|
||||
|
||||
|
||||
|
|
@ -46,6 +48,7 @@ async def bot(event_loop):
|
|||
async def test_get_me(bot: Bot, event_loop):
|
||||
""" getMe method test """
|
||||
from .types.dataset import USER
|
||||
|
||||
user = types.User(**USER)
|
||||
|
||||
async with FakeTelegram(message_dict=USER, loop=event_loop):
|
||||
|
|
@ -57,6 +60,7 @@ async def test_get_me(bot: Bot, event_loop):
|
|||
async def test_send_message(bot: Bot, event_loop):
|
||||
""" sendMessage method test """
|
||||
from .types.dataset import MESSAGE
|
||||
|
||||
msg = types.Message(**MESSAGE)
|
||||
|
||||
async with FakeTelegram(message_dict=MESSAGE, loop=event_loop):
|
||||
|
|
@ -68,11 +72,15 @@ async def test_send_message(bot: Bot, event_loop):
|
|||
async def test_forward_message(bot: Bot, event_loop):
|
||||
""" forwardMessage method test """
|
||||
from .types.dataset import FORWARDED_MESSAGE
|
||||
|
||||
msg = types.Message(**FORWARDED_MESSAGE)
|
||||
|
||||
async with FakeTelegram(message_dict=FORWARDED_MESSAGE, loop=event_loop):
|
||||
result = await bot.forward_message(chat_id=msg.chat.id, from_chat_id=msg.forward_from_chat.id,
|
||||
message_id=msg.forward_from_message_id)
|
||||
result = await bot.forward_message(
|
||||
chat_id=msg.chat.id,
|
||||
from_chat_id=msg.forward_from_chat.id,
|
||||
message_id=msg.forward_from_message_id,
|
||||
)
|
||||
assert result == msg
|
||||
|
||||
|
||||
|
|
@ -80,12 +88,18 @@ async def test_forward_message(bot: Bot, event_loop):
|
|||
async def test_send_photo(bot: Bot, event_loop):
|
||||
""" sendPhoto method test with file_id """
|
||||
from .types.dataset import MESSAGE_WITH_PHOTO, PHOTO
|
||||
|
||||
msg = types.Message(**MESSAGE_WITH_PHOTO)
|
||||
photo = types.PhotoSize(**PHOTO)
|
||||
|
||||
async with FakeTelegram(message_dict=MESSAGE_WITH_PHOTO, loop=event_loop):
|
||||
result = await bot.send_photo(msg.chat.id, photo=photo.file_id, caption=msg.caption,
|
||||
parse_mode=types.ParseMode.HTML, disable_notification=False)
|
||||
result = await bot.send_photo(
|
||||
msg.chat.id,
|
||||
photo=photo.file_id,
|
||||
caption=msg.caption,
|
||||
parse_mode=types.ParseMode.HTML,
|
||||
disable_notification=False,
|
||||
)
|
||||
assert result == msg
|
||||
|
||||
|
||||
|
|
@ -93,12 +107,20 @@ async def test_send_photo(bot: Bot, event_loop):
|
|||
async def test_send_audio(bot: Bot, event_loop):
|
||||
""" sendAudio method test with file_id """
|
||||
from .types.dataset import MESSAGE_WITH_AUDIO
|
||||
|
||||
msg = types.Message(**MESSAGE_WITH_AUDIO)
|
||||
|
||||
async with FakeTelegram(message_dict=MESSAGE_WITH_AUDIO, loop=event_loop):
|
||||
result = await bot.send_audio(chat_id=msg.chat.id, audio=msg.audio.file_id, caption=msg.caption,
|
||||
parse_mode=types.ParseMode.HTML, duration=msg.audio.duration,
|
||||
performer=msg.audio.performer, title=msg.audio.title, disable_notification=False)
|
||||
result = await bot.send_audio(
|
||||
chat_id=msg.chat.id,
|
||||
audio=msg.audio.file_id,
|
||||
caption=msg.caption,
|
||||
parse_mode=types.ParseMode.HTML,
|
||||
duration=msg.audio.duration,
|
||||
performer=msg.audio.performer,
|
||||
title=msg.audio.title,
|
||||
disable_notification=False,
|
||||
)
|
||||
assert result == msg
|
||||
|
||||
|
||||
|
|
@ -106,11 +128,17 @@ async def test_send_audio(bot: Bot, event_loop):
|
|||
async def test_send_document(bot: Bot, event_loop):
|
||||
""" sendDocument method test with file_id """
|
||||
from .types.dataset import MESSAGE_WITH_DOCUMENT
|
||||
|
||||
msg = types.Message(**MESSAGE_WITH_DOCUMENT)
|
||||
|
||||
async with FakeTelegram(message_dict=MESSAGE_WITH_DOCUMENT, loop=event_loop):
|
||||
result = await bot.send_document(chat_id=msg.chat.id, document=msg.document.file_id, caption=msg.caption,
|
||||
parse_mode=types.ParseMode.HTML, disable_notification=False)
|
||||
result = await bot.send_document(
|
||||
chat_id=msg.chat.id,
|
||||
document=msg.document.file_id,
|
||||
caption=msg.caption,
|
||||
parse_mode=types.ParseMode.HTML,
|
||||
disable_notification=False,
|
||||
)
|
||||
assert result == msg
|
||||
|
||||
|
||||
|
|
@ -118,14 +146,22 @@ async def test_send_document(bot: Bot, event_loop):
|
|||
async def test_send_video(bot: Bot, event_loop):
|
||||
""" sendVideo method test with file_id """
|
||||
from .types.dataset import MESSAGE_WITH_VIDEO, VIDEO
|
||||
|
||||
msg = types.Message(**MESSAGE_WITH_VIDEO)
|
||||
video = types.Video(**VIDEO)
|
||||
|
||||
async with FakeTelegram(message_dict=MESSAGE_WITH_VIDEO, loop=event_loop):
|
||||
result = await bot.send_video(chat_id=msg.chat.id, video=video.file_id, duration=video.duration,
|
||||
width=video.width, height=video.height, caption=msg.caption,
|
||||
parse_mode=types.ParseMode.HTML, supports_streaming=True,
|
||||
disable_notification=False)
|
||||
result = await bot.send_video(
|
||||
chat_id=msg.chat.id,
|
||||
video=video.file_id,
|
||||
duration=video.duration,
|
||||
width=video.width,
|
||||
height=video.height,
|
||||
caption=msg.caption,
|
||||
parse_mode=types.ParseMode.HTML,
|
||||
supports_streaming=True,
|
||||
disable_notification=False,
|
||||
)
|
||||
assert result == msg
|
||||
|
||||
|
||||
|
|
@ -133,13 +169,19 @@ async def test_send_video(bot: Bot, event_loop):
|
|||
async def test_send_voice(bot: Bot, event_loop):
|
||||
""" sendVoice method test with file_id """
|
||||
from .types.dataset import MESSAGE_WITH_VOICE, VOICE
|
||||
|
||||
msg = types.Message(**MESSAGE_WITH_VOICE)
|
||||
voice = types.Voice(**VOICE)
|
||||
|
||||
async with FakeTelegram(message_dict=MESSAGE_WITH_VOICE, loop=event_loop):
|
||||
result = await bot.send_voice(chat_id=msg.chat.id, voice=voice.file_id, caption=msg.caption,
|
||||
parse_mode=types.ParseMode.HTML, duration=voice.duration,
|
||||
disable_notification=False)
|
||||
result = await bot.send_voice(
|
||||
chat_id=msg.chat.id,
|
||||
voice=voice.file_id,
|
||||
caption=msg.caption,
|
||||
parse_mode=types.ParseMode.HTML,
|
||||
duration=voice.duration,
|
||||
disable_notification=False,
|
||||
)
|
||||
assert result == msg
|
||||
|
||||
|
||||
|
|
@ -147,13 +189,18 @@ async def test_send_voice(bot: Bot, event_loop):
|
|||
async def test_send_video_note(bot: Bot, event_loop):
|
||||
""" sendVideoNote method test with file_id """
|
||||
from .types.dataset import MESSAGE_WITH_VIDEO_NOTE, VIDEO_NOTE
|
||||
|
||||
msg = types.Message(**MESSAGE_WITH_VIDEO_NOTE)
|
||||
video_note = types.VideoNote(**VIDEO_NOTE)
|
||||
|
||||
async with FakeTelegram(message_dict=MESSAGE_WITH_VIDEO_NOTE, loop=event_loop):
|
||||
result = await bot.send_video_note(chat_id=msg.chat.id, video_note=video_note.file_id,
|
||||
duration=video_note.duration, length=video_note.length,
|
||||
disable_notification=False)
|
||||
result = await bot.send_video_note(
|
||||
chat_id=msg.chat.id,
|
||||
video_note=video_note.file_id,
|
||||
duration=video_note.duration,
|
||||
length=video_note.length,
|
||||
disable_notification=False,
|
||||
)
|
||||
assert result == msg
|
||||
|
||||
|
||||
|
|
@ -161,11 +208,17 @@ async def test_send_video_note(bot: Bot, event_loop):
|
|||
async def test_send_media_group(bot: Bot, event_loop):
|
||||
""" sendMediaGroup method test with file_id """
|
||||
from .types.dataset import MESSAGE_WITH_MEDIA_GROUP, PHOTO
|
||||
|
||||
msg = types.Message(**MESSAGE_WITH_MEDIA_GROUP)
|
||||
photo = types.PhotoSize(**PHOTO)
|
||||
media = [types.InputMediaPhoto(media=photo.file_id), types.InputMediaPhoto(media=photo.file_id)]
|
||||
media = [
|
||||
types.InputMediaPhoto(media=photo.file_id),
|
||||
types.InputMediaPhoto(media=photo.file_id),
|
||||
]
|
||||
|
||||
async with FakeTelegram(message_dict=[MESSAGE_WITH_MEDIA_GROUP, MESSAGE_WITH_MEDIA_GROUP], loop=event_loop):
|
||||
async with FakeTelegram(
|
||||
message_dict=[MESSAGE_WITH_MEDIA_GROUP, MESSAGE_WITH_MEDIA_GROUP], loop=event_loop
|
||||
):
|
||||
result = await bot.send_media_group(msg.chat.id, media=media, disable_notification=False)
|
||||
assert len(result) == len(media)
|
||||
assert result.pop().media_group_id
|
||||
|
|
@ -175,12 +228,18 @@ async def test_send_media_group(bot: Bot, event_loop):
|
|||
async def test_send_location(bot: Bot, event_loop):
|
||||
""" sendLocation method test """
|
||||
from .types.dataset import MESSAGE_WITH_LOCATION, LOCATION
|
||||
|
||||
msg = types.Message(**MESSAGE_WITH_LOCATION)
|
||||
location = types.Location(**LOCATION)
|
||||
|
||||
async with FakeTelegram(message_dict=MESSAGE_WITH_LOCATION, loop=event_loop):
|
||||
result = await bot.send_location(msg.chat.id, latitude=location.latitude, longitude=location.longitude,
|
||||
live_period=10, disable_notification=False)
|
||||
result = await bot.send_location(
|
||||
msg.chat.id,
|
||||
latitude=location.latitude,
|
||||
longitude=location.longitude,
|
||||
live_period=10,
|
||||
disable_notification=False,
|
||||
)
|
||||
assert result == msg
|
||||
|
||||
|
||||
|
|
@ -188,13 +247,18 @@ async def test_send_location(bot: Bot, event_loop):
|
|||
async def test_edit_message_live_location_by_bot(bot: Bot, event_loop):
|
||||
""" editMessageLiveLocation method test """
|
||||
from .types.dataset import MESSAGE_WITH_LOCATION, LOCATION
|
||||
|
||||
msg = types.Message(**MESSAGE_WITH_LOCATION)
|
||||
location = types.Location(**LOCATION)
|
||||
|
||||
# editing bot message
|
||||
async with FakeTelegram(message_dict=MESSAGE_WITH_LOCATION, loop=event_loop):
|
||||
result = await bot.edit_message_live_location(chat_id=msg.chat.id, message_id=msg.message_id,
|
||||
latitude=location.latitude, longitude=location.longitude)
|
||||
result = await bot.edit_message_live_location(
|
||||
chat_id=msg.chat.id,
|
||||
message_id=msg.message_id,
|
||||
latitude=location.latitude,
|
||||
longitude=location.longitude,
|
||||
)
|
||||
assert result == msg
|
||||
|
||||
|
||||
|
|
@ -202,13 +266,18 @@ async def test_edit_message_live_location_by_bot(bot: Bot, event_loop):
|
|||
async def test_edit_message_live_location_by_user(bot: Bot, event_loop):
|
||||
""" editMessageLiveLocation method test """
|
||||
from .types.dataset import MESSAGE_WITH_LOCATION, LOCATION
|
||||
|
||||
msg = types.Message(**MESSAGE_WITH_LOCATION)
|
||||
location = types.Location(**LOCATION)
|
||||
|
||||
# editing user's message
|
||||
async with FakeTelegram(message_dict=True, loop=event_loop):
|
||||
result = await bot.edit_message_live_location(chat_id=msg.chat.id, message_id=msg.message_id,
|
||||
latitude=location.latitude, longitude=location.longitude)
|
||||
result = await bot.edit_message_live_location(
|
||||
chat_id=msg.chat.id,
|
||||
message_id=msg.message_id,
|
||||
latitude=location.latitude,
|
||||
longitude=location.longitude,
|
||||
)
|
||||
assert isinstance(result, bool) and result is True
|
||||
|
||||
|
||||
|
|
@ -216,11 +285,14 @@ async def test_edit_message_live_location_by_user(bot: Bot, event_loop):
|
|||
async def test_stop_message_live_location_by_bot(bot: Bot, event_loop):
|
||||
""" stopMessageLiveLocation method test """
|
||||
from .types.dataset import MESSAGE_WITH_LOCATION
|
||||
|
||||
msg = types.Message(**MESSAGE_WITH_LOCATION)
|
||||
|
||||
# stopping bot message
|
||||
async with FakeTelegram(message_dict=MESSAGE_WITH_LOCATION, loop=event_loop):
|
||||
result = await bot.stop_message_live_location(chat_id=msg.chat.id, message_id=msg.message_id)
|
||||
result = await bot.stop_message_live_location(
|
||||
chat_id=msg.chat.id, message_id=msg.message_id
|
||||
)
|
||||
assert result == msg
|
||||
|
||||
|
||||
|
|
@ -228,11 +300,14 @@ async def test_stop_message_live_location_by_bot(bot: Bot, event_loop):
|
|||
async def test_stop_message_live_location_by_user(bot: Bot, event_loop):
|
||||
""" stopMessageLiveLocation method test """
|
||||
from .types.dataset import MESSAGE_WITH_LOCATION
|
||||
|
||||
msg = types.Message(**MESSAGE_WITH_LOCATION)
|
||||
|
||||
# stopping user's message
|
||||
async with FakeTelegram(message_dict=True, loop=event_loop):
|
||||
result = await bot.stop_message_live_location(chat_id=msg.chat.id, message_id=msg.message_id)
|
||||
result = await bot.stop_message_live_location(
|
||||
chat_id=msg.chat.id, message_id=msg.message_id
|
||||
)
|
||||
assert isinstance(result, bool)
|
||||
assert result is True
|
||||
|
||||
|
|
@ -241,14 +316,21 @@ async def test_stop_message_live_location_by_user(bot: Bot, event_loop):
|
|||
async def test_send_venue(bot: Bot, event_loop):
|
||||
""" sendVenue method test """
|
||||
from .types.dataset import MESSAGE_WITH_VENUE, VENUE, LOCATION
|
||||
|
||||
msg = types.Message(**MESSAGE_WITH_VENUE)
|
||||
location = types.Location(**LOCATION)
|
||||
venue = types.Venue(**VENUE)
|
||||
|
||||
async with FakeTelegram(message_dict=MESSAGE_WITH_VENUE, loop=event_loop):
|
||||
result = await bot.send_venue(msg.chat.id, latitude=location.latitude, longitude=location.longitude,
|
||||
title=venue.title, address=venue.address, foursquare_id=venue.foursquare_id,
|
||||
disable_notification=False)
|
||||
result = await bot.send_venue(
|
||||
msg.chat.id,
|
||||
latitude=location.latitude,
|
||||
longitude=location.longitude,
|
||||
title=venue.title,
|
||||
address=venue.address,
|
||||
foursquare_id=venue.foursquare_id,
|
||||
disable_notification=False,
|
||||
)
|
||||
assert result == msg
|
||||
|
||||
|
||||
|
|
@ -256,12 +338,18 @@ async def test_send_venue(bot: Bot, event_loop):
|
|||
async def test_send_contact(bot: Bot, event_loop):
|
||||
""" sendContact method test """
|
||||
from .types.dataset import MESSAGE_WITH_CONTACT, CONTACT
|
||||
|
||||
msg = types.Message(**MESSAGE_WITH_CONTACT)
|
||||
contact = types.Contact(**CONTACT)
|
||||
|
||||
async with FakeTelegram(message_dict=MESSAGE_WITH_CONTACT, loop=event_loop):
|
||||
result = await bot.send_contact(msg.chat.id, phone_number=contact.phone_number, first_name=contact.first_name,
|
||||
last_name=contact.last_name, disable_notification=False)
|
||||
result = await bot.send_contact(
|
||||
msg.chat.id,
|
||||
phone_number=contact.phone_number,
|
||||
first_name=contact.first_name,
|
||||
last_name=contact.last_name,
|
||||
disable_notification=False,
|
||||
)
|
||||
assert result == msg
|
||||
|
||||
|
||||
|
|
@ -269,6 +357,7 @@ async def test_send_contact(bot: Bot, event_loop):
|
|||
async def test_send_chat_action(bot: Bot, event_loop):
|
||||
""" sendChatAction method test """
|
||||
from .types.dataset import CHAT
|
||||
|
||||
chat = types.Chat(**CHAT)
|
||||
|
||||
async with FakeTelegram(message_dict=True, loop=event_loop):
|
||||
|
|
@ -281,6 +370,7 @@ async def test_send_chat_action(bot: Bot, event_loop):
|
|||
async def test_get_user_profile_photo(bot: Bot, event_loop):
|
||||
""" getUserProfilePhotos method test """
|
||||
from .types.dataset import USER_PROFILE_PHOTOS, USER
|
||||
|
||||
user = types.User(**USER)
|
||||
|
||||
async with FakeTelegram(message_dict=USER_PROFILE_PHOTOS, loop=event_loop):
|
||||
|
|
@ -292,6 +382,7 @@ async def test_get_user_profile_photo(bot: Bot, event_loop):
|
|||
async def test_get_file(bot: Bot, event_loop):
|
||||
""" getFile method test """
|
||||
from .types.dataset import FILE
|
||||
|
||||
file = types.File(**FILE)
|
||||
|
||||
async with FakeTelegram(message_dict=FILE, loop=event_loop):
|
||||
|
|
@ -303,6 +394,7 @@ async def test_get_file(bot: Bot, event_loop):
|
|||
async def test_kick_chat_member(bot: Bot, event_loop):
|
||||
""" kickChatMember method test """
|
||||
from .types.dataset import USER, CHAT
|
||||
|
||||
user = types.User(**USER)
|
||||
chat = types.Chat(**CHAT)
|
||||
|
||||
|
|
@ -316,6 +408,7 @@ async def test_kick_chat_member(bot: Bot, event_loop):
|
|||
async def test_unban_chat_member(bot: Bot, event_loop):
|
||||
""" unbanChatMember method test """
|
||||
from .types.dataset import USER, CHAT
|
||||
|
||||
user = types.User(**USER)
|
||||
chat = types.Chat(**CHAT)
|
||||
|
||||
|
|
@ -329,13 +422,20 @@ async def test_unban_chat_member(bot: Bot, event_loop):
|
|||
async def test_restrict_chat_member(bot: Bot, event_loop):
|
||||
""" restrictChatMember method test """
|
||||
from .types.dataset import USER, CHAT
|
||||
|
||||
user = types.User(**USER)
|
||||
chat = types.Chat(**CHAT)
|
||||
|
||||
async with FakeTelegram(message_dict=True, loop=event_loop):
|
||||
result = await bot.restrict_chat_member(chat_id=chat.id, user_id=user.id, can_add_web_page_previews=False,
|
||||
can_send_media_messages=False, can_send_messages=False,
|
||||
can_send_other_messages=False, until_date=123)
|
||||
result = await bot.restrict_chat_member(
|
||||
chat_id=chat.id,
|
||||
user_id=user.id,
|
||||
can_add_web_page_previews=False,
|
||||
can_send_media_messages=False,
|
||||
can_send_messages=False,
|
||||
can_send_other_messages=False,
|
||||
until_date=123,
|
||||
)
|
||||
assert isinstance(result, bool)
|
||||
assert result is True
|
||||
|
||||
|
|
@ -344,14 +444,23 @@ async def test_restrict_chat_member(bot: Bot, event_loop):
|
|||
async def test_promote_chat_member(bot: Bot, event_loop):
|
||||
""" promoteChatMember method test """
|
||||
from .types.dataset import USER, CHAT
|
||||
|
||||
user = types.User(**USER)
|
||||
chat = types.Chat(**CHAT)
|
||||
|
||||
async with FakeTelegram(message_dict=True, loop=event_loop):
|
||||
result = await bot.promote_chat_member(chat_id=chat.id, user_id=user.id, can_change_info=True,
|
||||
can_delete_messages=True, can_edit_messages=True,
|
||||
can_invite_users=True, can_pin_messages=True, can_post_messages=True,
|
||||
can_promote_members=True, can_restrict_members=True)
|
||||
result = await bot.promote_chat_member(
|
||||
chat_id=chat.id,
|
||||
user_id=user.id,
|
||||
can_change_info=True,
|
||||
can_delete_messages=True,
|
||||
can_edit_messages=True,
|
||||
can_invite_users=True,
|
||||
can_pin_messages=True,
|
||||
can_post_messages=True,
|
||||
can_promote_members=True,
|
||||
can_restrict_members=True,
|
||||
)
|
||||
assert isinstance(result, bool)
|
||||
assert result is True
|
||||
|
||||
|
|
@ -360,6 +469,7 @@ async def test_promote_chat_member(bot: Bot, event_loop):
|
|||
async def test_export_chat_invite_link(bot: Bot, event_loop):
|
||||
""" exportChatInviteLink method test """
|
||||
from .types.dataset import CHAT, INVITE_LINK
|
||||
|
||||
chat = types.Chat(**CHAT)
|
||||
|
||||
async with FakeTelegram(message_dict=INVITE_LINK, loop=event_loop):
|
||||
|
|
@ -371,6 +481,7 @@ async def test_export_chat_invite_link(bot: Bot, event_loop):
|
|||
async def test_delete_chat_photo(bot: Bot, event_loop):
|
||||
""" deleteChatPhoto method test """
|
||||
from .types.dataset import CHAT
|
||||
|
||||
chat = types.Chat(**CHAT)
|
||||
|
||||
async with FakeTelegram(message_dict=True, loop=event_loop):
|
||||
|
|
@ -383,10 +494,11 @@ async def test_delete_chat_photo(bot: Bot, event_loop):
|
|||
async def test_set_chat_title(bot: Bot, event_loop):
|
||||
""" setChatTitle method test """
|
||||
from .types.dataset import CHAT
|
||||
|
||||
chat = types.Chat(**CHAT)
|
||||
|
||||
async with FakeTelegram(message_dict=True, loop=event_loop):
|
||||
result = await bot.set_chat_title(chat_id=chat.id, title='Test title')
|
||||
result = await bot.set_chat_title(chat_id=chat.id, title="Test title")
|
||||
assert isinstance(result, bool)
|
||||
assert result is True
|
||||
|
||||
|
|
@ -395,10 +507,11 @@ async def test_set_chat_title(bot: Bot, event_loop):
|
|||
async def test_set_chat_description(bot: Bot, event_loop):
|
||||
""" setChatDescription method test """
|
||||
from .types.dataset import CHAT
|
||||
|
||||
chat = types.Chat(**CHAT)
|
||||
|
||||
async with FakeTelegram(message_dict=True, loop=event_loop):
|
||||
result = await bot.set_chat_description(chat_id=chat.id, description='Test description')
|
||||
result = await bot.set_chat_description(chat_id=chat.id, description="Test description")
|
||||
assert isinstance(result, bool)
|
||||
assert result is True
|
||||
|
||||
|
|
@ -407,11 +520,13 @@ async def test_set_chat_description(bot: Bot, event_loop):
|
|||
async def test_pin_chat_message(bot: Bot, event_loop):
|
||||
""" pinChatMessage method test """
|
||||
from .types.dataset import MESSAGE
|
||||
|
||||
message = types.Message(**MESSAGE)
|
||||
|
||||
async with FakeTelegram(message_dict=True, loop=event_loop):
|
||||
result = await bot.pin_chat_message(chat_id=message.chat.id, message_id=message.message_id,
|
||||
disable_notification=False)
|
||||
result = await bot.pin_chat_message(
|
||||
chat_id=message.chat.id, message_id=message.message_id, disable_notification=False
|
||||
)
|
||||
assert isinstance(result, bool)
|
||||
assert result is True
|
||||
|
||||
|
|
@ -420,6 +535,7 @@ async def test_pin_chat_message(bot: Bot, event_loop):
|
|||
async def test_unpin_chat_message(bot: Bot, event_loop):
|
||||
""" unpinChatMessage method test """
|
||||
from .types.dataset import CHAT
|
||||
|
||||
chat = types.Chat(**CHAT)
|
||||
|
||||
async with FakeTelegram(message_dict=True, loop=event_loop):
|
||||
|
|
@ -432,6 +548,7 @@ async def test_unpin_chat_message(bot: Bot, event_loop):
|
|||
async def test_leave_chat(bot: Bot, event_loop):
|
||||
""" leaveChat method test """
|
||||
from .types.dataset import CHAT
|
||||
|
||||
chat = types.Chat(**CHAT)
|
||||
|
||||
async with FakeTelegram(message_dict=True, loop=event_loop):
|
||||
|
|
@ -444,6 +561,7 @@ async def test_leave_chat(bot: Bot, event_loop):
|
|||
async def test_get_chat(bot: Bot, event_loop):
|
||||
""" getChat method test """
|
||||
from .types.dataset import CHAT
|
||||
|
||||
chat = types.Chat(**CHAT)
|
||||
|
||||
async with FakeTelegram(message_dict=CHAT, loop=event_loop):
|
||||
|
|
@ -455,6 +573,7 @@ async def test_get_chat(bot: Bot, event_loop):
|
|||
async def test_get_chat_administrators(bot: Bot, event_loop):
|
||||
""" getChatAdministrators method test """
|
||||
from .types.dataset import CHAT, CHAT_MEMBER
|
||||
|
||||
chat = types.Chat(**CHAT)
|
||||
member = types.ChatMember(**CHAT_MEMBER)
|
||||
|
||||
|
|
@ -468,6 +587,7 @@ async def test_get_chat_administrators(bot: Bot, event_loop):
|
|||
async def test_get_chat_members_count(bot: Bot, event_loop):
|
||||
""" getChatMembersCount method test """
|
||||
from .types.dataset import CHAT
|
||||
|
||||
chat = types.Chat(**CHAT)
|
||||
count = 5
|
||||
|
||||
|
|
@ -480,6 +600,7 @@ async def test_get_chat_members_count(bot: Bot, event_loop):
|
|||
async def test_get_chat_member(bot: Bot, event_loop):
|
||||
""" getChatMember method test """
|
||||
from .types.dataset import CHAT, CHAT_MEMBER
|
||||
|
||||
chat = types.Chat(**CHAT)
|
||||
member = types.ChatMember(**CHAT_MEMBER)
|
||||
|
||||
|
|
@ -493,10 +614,13 @@ async def test_get_chat_member(bot: Bot, event_loop):
|
|||
async def test_set_chat_sticker_set(bot: Bot, event_loop):
|
||||
""" setChatStickerSet method test """
|
||||
from .types.dataset import CHAT
|
||||
|
||||
chat = types.Chat(**CHAT)
|
||||
|
||||
async with FakeTelegram(message_dict=True, loop=event_loop):
|
||||
result = await bot.set_chat_sticker_set(chat_id=chat.id, sticker_set_name='aiogram_stickers')
|
||||
result = await bot.set_chat_sticker_set(
|
||||
chat_id=chat.id, sticker_set_name="aiogram_stickers"
|
||||
)
|
||||
assert isinstance(result, bool)
|
||||
assert result is True
|
||||
|
||||
|
|
@ -505,6 +629,7 @@ async def test_set_chat_sticker_set(bot: Bot, event_loop):
|
|||
async def test_delete_chat_sticker_set(bot: Bot, event_loop):
|
||||
""" setChatStickerSet method test """
|
||||
from .types.dataset import CHAT
|
||||
|
||||
chat = types.Chat(**CHAT)
|
||||
|
||||
async with FakeTelegram(message_dict=True, loop=event_loop):
|
||||
|
|
@ -518,7 +643,7 @@ async def test_answer_callback_query(bot: Bot, event_loop):
|
|||
""" answerCallbackQuery method test """
|
||||
|
||||
async with FakeTelegram(message_dict=True, loop=event_loop):
|
||||
result = await bot.answer_callback_query(callback_query_id='QuERyId', text='Test Answer')
|
||||
result = await bot.answer_callback_query(callback_query_id="QuERyId", text="Test Answer")
|
||||
assert isinstance(result, bool)
|
||||
assert result is True
|
||||
|
||||
|
|
@ -527,11 +652,14 @@ async def test_answer_callback_query(bot: Bot, event_loop):
|
|||
async def test_edit_message_text_by_bot(bot: Bot, event_loop):
|
||||
""" editMessageText method test """
|
||||
from .types.dataset import EDITED_MESSAGE
|
||||
|
||||
msg = types.Message(**EDITED_MESSAGE)
|
||||
|
||||
# message by bot
|
||||
async with FakeTelegram(message_dict=EDITED_MESSAGE, loop=event_loop):
|
||||
result = await bot.edit_message_text(text=msg.text, chat_id=msg.chat.id, message_id=msg.message_id)
|
||||
result = await bot.edit_message_text(
|
||||
text=msg.text, chat_id=msg.chat.id, message_id=msg.message_id
|
||||
)
|
||||
assert result == msg
|
||||
|
||||
|
||||
|
|
@ -539,10 +667,13 @@ async def test_edit_message_text_by_bot(bot: Bot, event_loop):
|
|||
async def test_edit_message_text_by_user(bot: Bot, event_loop):
|
||||
""" editMessageText method test """
|
||||
from .types.dataset import EDITED_MESSAGE
|
||||
|
||||
msg = types.Message(**EDITED_MESSAGE)
|
||||
|
||||
# message by user
|
||||
async with FakeTelegram(message_dict=True, loop=event_loop):
|
||||
result = await bot.edit_message_text(text=msg.text, chat_id=msg.chat.id, message_id=msg.message_id)
|
||||
result = await bot.edit_message_text(
|
||||
text=msg.text, chat_id=msg.chat.id, message_id=msg.message_id
|
||||
)
|
||||
assert isinstance(result, bool)
|
||||
assert result is True
|
||||
|
|
|
|||
|
|
@ -8,8 +8,7 @@ pytestmark = pytest.mark.asyncio
|
|||
@pytest.yield_fixture()
|
||||
async def bot(event_loop):
|
||||
""" Bot fixture """
|
||||
_bot = Bot(token='123456789:AABBCCDDEEFFaabbccddeeff-1234567890',
|
||||
loop=event_loop)
|
||||
_bot = Bot(token="123456789:AABBCCDDEEFFaabbccddeeff-1234567890", loop=event_loop)
|
||||
yield _bot
|
||||
await _bot.close()
|
||||
|
||||
|
|
@ -25,7 +24,7 @@ class TestDispatcherInit:
|
|||
dp = Dispatcher(bot=bot)
|
||||
assert isinstance(dp, Dispatcher)
|
||||
|
||||
@pytest.mark.parametrize("bot_instance", [None, Bot, 123, 'abc'])
|
||||
@pytest.mark.parametrize("bot_instance", [None, Bot, 123, "abc"])
|
||||
async def test_wrong_bot_instance(self, bot_instance):
|
||||
"""
|
||||
User provides wrong data to 'bot' argument.
|
||||
|
|
|
|||
|
|
@ -26,6 +26,7 @@ async def message(bot, event_loop):
|
|||
:type event_loop: BaseEventLoop
|
||||
"""
|
||||
from .types.dataset import MESSAGE
|
||||
|
||||
msg = types.Message(**MESSAGE)
|
||||
|
||||
async with FakeTelegram(message_dict=MESSAGE, loop=event_loop):
|
||||
|
|
@ -44,4 +45,4 @@ class TestMiscCases:
|
|||
:return: RuntimeError with reason and help
|
||||
"""
|
||||
with pytest.raises(RuntimeError):
|
||||
await message.edit_text('test_calling_bot_not_from_context')
|
||||
await message.edit_text("test_calling_bot_not_from_context")
|
||||
|
|
|
|||
|
|
@ -3,24 +3,24 @@ import pytest
|
|||
from aiogram.bot import api
|
||||
from aiogram.utils import auth_widget, exceptions
|
||||
|
||||
VALID_TOKEN = '123456789:AABBCCDDEEFFaabbccddeeff-1234567890'
|
||||
INVALID_TOKEN = '123456789:AABBCCDDEEFFaabbccddeeff 123456789' # Space in token and wrong length
|
||||
VALID_TOKEN = "123456789:AABBCCDDEEFFaabbccddeeff-1234567890"
|
||||
INVALID_TOKEN = "123456789:AABBCCDDEEFFaabbccddeeff 123456789" # Space in token and wrong length
|
||||
|
||||
VALID_DATA = {
|
||||
'date': 1525385236,
|
||||
'first_name': 'Test',
|
||||
'last_name': 'User',
|
||||
'id': 123456789,
|
||||
'username': 'username',
|
||||
'hash': '69a9871558fbbe4cd0dbaba52fa1cc4f38315d3245b7504381a64139fb024b5b'
|
||||
"date": 1525385236,
|
||||
"first_name": "Test",
|
||||
"last_name": "User",
|
||||
"id": 123456789,
|
||||
"username": "username",
|
||||
"hash": "69a9871558fbbe4cd0dbaba52fa1cc4f38315d3245b7504381a64139fb024b5b",
|
||||
}
|
||||
INVALID_DATA = {
|
||||
'date': 1525385237,
|
||||
'first_name': 'Test',
|
||||
'last_name': 'User',
|
||||
'id': 123456789,
|
||||
'username': 'username',
|
||||
'hash': '69a9871558fbbe4cd0dbaba52fa1cc4f38315d3245b7504381a64139fb024b5b'
|
||||
"date": 1525385237,
|
||||
"first_name": "Test",
|
||||
"last_name": "User",
|
||||
"id": 123456789,
|
||||
"username": "username",
|
||||
"hash": "69a9871558fbbe4cd0dbaba52fa1cc4f38315d3245b7504381a64139fb024b5b",
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ USER = {
|
|||
"first_name": "FirstName",
|
||||
"last_name": "LastName",
|
||||
"username": "username",
|
||||
"language_code": "ru"
|
||||
"language_code": "ru",
|
||||
}
|
||||
|
||||
CHAT = {
|
||||
|
|
@ -16,14 +16,14 @@ CHAT = {
|
|||
"first_name": "FirstName",
|
||||
"last_name": "LastName",
|
||||
"username": "username",
|
||||
"type": "private"
|
||||
"type": "private",
|
||||
}
|
||||
|
||||
PHOTO = {
|
||||
"file_id": "AgADBAADFak0G88YZAf8OAug7bHyS9x2ZxkABHVfpJywcloRAAGAAQABAg",
|
||||
"file_size": 1101,
|
||||
"width": 90,
|
||||
"height": 51
|
||||
"height": 51,
|
||||
}
|
||||
|
||||
AUDIO = {
|
||||
|
|
@ -32,7 +32,7 @@ AUDIO = {
|
|||
"title": "The Best Song",
|
||||
"performer": "The Best Singer",
|
||||
"file_id": "CQADAgADbQEAAsnrIUpNoRRNsH7_hAI",
|
||||
"file_size": 9507774
|
||||
"file_size": 9507774,
|
||||
}
|
||||
|
||||
CHAT_MEMBER = {
|
||||
|
|
@ -44,20 +44,16 @@ CHAT_MEMBER = {
|
|||
"can_invite_users": True,
|
||||
"can_restrict_members": True,
|
||||
"can_pin_messages": True,
|
||||
"can_promote_members": False
|
||||
"can_promote_members": False,
|
||||
}
|
||||
|
||||
CONTACT = {
|
||||
"phone_number": "88005553535",
|
||||
"first_name": "John",
|
||||
"last_name": "Smith",
|
||||
}
|
||||
CONTACT = {"phone_number": "88005553535", "first_name": "John", "last_name": "Smith"}
|
||||
|
||||
DOCUMENT = {
|
||||
"file_name": "test.docx",
|
||||
"mime_type": "application/vnd.openxmlformats-officedocument.wordprocessingml.document",
|
||||
"file_id": "BQADAgADpgADy_JxS66XQTBRHFleAg",
|
||||
"file_size": 21331
|
||||
"file_size": 21331,
|
||||
}
|
||||
|
||||
ANIMATION = {
|
||||
|
|
@ -65,74 +61,46 @@ ANIMATION = {
|
|||
"mime_type": "video/mp4",
|
||||
"thumb": PHOTO,
|
||||
"file_id": "CgADBAAD4DUAAoceZAe2WiE9y0crrAI",
|
||||
"file_size": 65837
|
||||
"file_size": 65837,
|
||||
}
|
||||
|
||||
ENTITY_BOLD = {
|
||||
"offset": 5,
|
||||
"length": 2,
|
||||
"type": "bold"
|
||||
}
|
||||
ENTITY_BOLD = {"offset": 5, "length": 2, "type": "bold"}
|
||||
|
||||
ENTITY_ITALIC = {
|
||||
"offset": 8,
|
||||
"length": 1,
|
||||
"type": "italic"
|
||||
}
|
||||
ENTITY_ITALIC = {"offset": 8, "length": 1, "type": "italic"}
|
||||
|
||||
ENTITY_LINK = {
|
||||
"offset": 10,
|
||||
"length": 6,
|
||||
"type": "text_link",
|
||||
"url": "http://google.com/"
|
||||
}
|
||||
ENTITY_LINK = {"offset": 10, "length": 6, "type": "text_link", "url": "http://google.com/"}
|
||||
|
||||
ENTITY_CODE = {
|
||||
"offset": 17,
|
||||
"length": 7,
|
||||
"type": "code"
|
||||
}
|
||||
ENTITY_CODE = {"offset": 17, "length": 7, "type": "code"}
|
||||
|
||||
ENTITY_PRE = {
|
||||
"offset": 30,
|
||||
"length": 4,
|
||||
"type": "pre"
|
||||
}
|
||||
ENTITY_PRE = {"offset": 30, "length": 4, "type": "pre"}
|
||||
|
||||
ENTITY_MENTION = {
|
||||
"offset": 47,
|
||||
"length": 9,
|
||||
"type": "mention"
|
||||
}
|
||||
ENTITY_MENTION = {"offset": 47, "length": 9, "type": "mention"}
|
||||
|
||||
GAME = {
|
||||
"title": "Karate Kido",
|
||||
"description": "No trees were harmed in the making of this game :)",
|
||||
"photo": [PHOTO, PHOTO, PHOTO],
|
||||
"animation": ANIMATION
|
||||
"animation": ANIMATION,
|
||||
}
|
||||
|
||||
INVOICE = {
|
||||
"title": "Working Time Machine",
|
||||
"description": "Want to visit your great-great-great-grandparents? "
|
||||
"Make a fortune at the races? "
|
||||
"Shake hands with Hammurabi and take a stroll in the Hanging Gardens? "
|
||||
"Order our Working Time Machine today!",
|
||||
"Make a fortune at the races? "
|
||||
"Shake hands with Hammurabi and take a stroll in the Hanging Gardens? "
|
||||
"Order our Working Time Machine today!",
|
||||
"start_parameter": "time-machine-example",
|
||||
"currency": "USD",
|
||||
"total_amount": 6250
|
||||
"total_amount": 6250,
|
||||
}
|
||||
|
||||
LOCATION = {
|
||||
"latitude": 50.693416,
|
||||
"longitude": 30.624605
|
||||
}
|
||||
LOCATION = {"latitude": 50.693416, "longitude": 30.624605}
|
||||
|
||||
VENUE = {
|
||||
"location": LOCATION,
|
||||
"title": "Venue Name",
|
||||
"address": "Venue Address",
|
||||
"foursquare_id": "4e6f2cec483bad563d150f98"
|
||||
"foursquare_id": "4e6f2cec483bad563d150f98",
|
||||
}
|
||||
|
||||
SHIPPING_ADDRESS = {
|
||||
|
|
@ -141,7 +109,7 @@ SHIPPING_ADDRESS = {
|
|||
"city": "DefaultCity",
|
||||
"street_line1": "Central",
|
||||
"street_line2": "Middle",
|
||||
"post_code": "424242"
|
||||
"post_code": "424242",
|
||||
}
|
||||
|
||||
STICKER = {
|
||||
|
|
@ -153,10 +121,10 @@ STICKER = {
|
|||
"file_id": "AAbbCCddEEffGGhh1234567890",
|
||||
"file_size": 1234,
|
||||
"width": 128,
|
||||
"height": 128
|
||||
"height": 128,
|
||||
},
|
||||
"file_id": "AAbbCCddEEffGGhh1234567890",
|
||||
"file_size": 12345
|
||||
"file_size": 12345,
|
||||
}
|
||||
|
||||
SUCCESSFUL_PAYMENT = {
|
||||
|
|
@ -164,7 +132,7 @@ SUCCESSFUL_PAYMENT = {
|
|||
"total_amount": 6250,
|
||||
"invoice_payload": "HAPPY FRIDAYS COUPON",
|
||||
"telegram_payment_charge_id": "_",
|
||||
"provider_payment_charge_id": "12345678901234_test"
|
||||
"provider_payment_charge_id": "12345678901234_test",
|
||||
}
|
||||
|
||||
VIDEO = {
|
||||
|
|
@ -174,7 +142,7 @@ VIDEO = {
|
|||
"mime_type": "video/quicktime",
|
||||
"thumb": PHOTO,
|
||||
"file_id": "BAADAgpAADdawy_JxS72kRvV3cortAg",
|
||||
"file_size": 10099782
|
||||
"file_size": 10099782,
|
||||
}
|
||||
|
||||
VIDEO_NOTE = {
|
||||
|
|
@ -182,14 +150,14 @@ VIDEO_NOTE = {
|
|||
"length": 240,
|
||||
"thumb": PHOTO,
|
||||
"file_id": "AbCdEfGhIjKlMnOpQrStUvWxYz",
|
||||
"file_size": 186562
|
||||
"file_size": 186562,
|
||||
}
|
||||
|
||||
VOICE = {
|
||||
"duration": 1,
|
||||
"mime_type": "audio/ogg",
|
||||
"file_id": "AwADawAgADADy_JxS2gopIVIIxlhAg",
|
||||
"file_size": 4321
|
||||
"file_size": 4321,
|
||||
}
|
||||
|
||||
CALLBACK_QUERY = {}
|
||||
|
|
@ -206,7 +174,7 @@ EDITED_MESSAGE = {
|
|||
"chat": CHAT,
|
||||
"date": 1508825372,
|
||||
"edit_date": 1508825379,
|
||||
"text": "hi there (edited)"
|
||||
"text": "hi there (edited)",
|
||||
}
|
||||
|
||||
FORWARDED_MESSAGE = {
|
||||
|
|
@ -218,8 +186,15 @@ FORWARDED_MESSAGE = {
|
|||
"forward_from_message_id": 123,
|
||||
"forward_date": 1522749037,
|
||||
"text": "Forwarded text with entities from public channel ",
|
||||
"entities": [ENTITY_BOLD, ENTITY_CODE, ENTITY_ITALIC, ENTITY_LINK,
|
||||
ENTITY_LINK, ENTITY_MENTION, ENTITY_PRE]
|
||||
"entities": [
|
||||
ENTITY_BOLD,
|
||||
ENTITY_CODE,
|
||||
ENTITY_ITALIC,
|
||||
ENTITY_LINK,
|
||||
ENTITY_LINK,
|
||||
ENTITY_MENTION,
|
||||
ENTITY_PRE,
|
||||
],
|
||||
}
|
||||
|
||||
INLINE_QUERY = {}
|
||||
|
|
@ -229,7 +204,7 @@ MESSAGE = {
|
|||
"from": USER,
|
||||
"chat": CHAT,
|
||||
"date": 1508709711,
|
||||
"text": "Hi, world!"
|
||||
"text": "Hi, world!",
|
||||
}
|
||||
|
||||
MESSAGE_WITH_AUDIO = {
|
||||
|
|
@ -238,7 +213,7 @@ MESSAGE_WITH_AUDIO = {
|
|||
"chat": CHAT,
|
||||
"date": 1508739776,
|
||||
"audio": AUDIO,
|
||||
"caption": "This is my favourite song"
|
||||
"caption": "This is my favourite song",
|
||||
}
|
||||
|
||||
MESSAGE_WITH_AUTHOR_SIGNATURE = {}
|
||||
|
|
@ -250,7 +225,7 @@ MESSAGE_WITH_CONTACT = {
|
|||
"from": USER,
|
||||
"chat": CHAT,
|
||||
"date": 1522850298,
|
||||
"contact": CONTACT
|
||||
"contact": CONTACT,
|
||||
}
|
||||
|
||||
MESSAGE_WITH_DELETE_CHAT_PHOTO = {}
|
||||
|
|
@ -261,7 +236,7 @@ MESSAGE_WITH_DOCUMENT = {
|
|||
"chat": CHAT,
|
||||
"date": 1508768012,
|
||||
"document": DOCUMENT,
|
||||
"caption": "Read my document"
|
||||
"caption": "Read my document",
|
||||
}
|
||||
|
||||
MESSAGE_WITH_EDIT_DATE = {}
|
||||
|
|
@ -273,7 +248,7 @@ MESSAGE_WITH_GAME = {
|
|||
"from": USER,
|
||||
"chat": CHAT,
|
||||
"date": 1508824810,
|
||||
"game": GAME
|
||||
"game": GAME,
|
||||
}
|
||||
|
||||
MESSAGE_WITH_GROUP_CHAT_CREATED = {}
|
||||
|
|
@ -283,7 +258,7 @@ MESSAGE_WITH_INVOICE = {
|
|||
"from": USER,
|
||||
"chat": CHAT,
|
||||
"date": 1508761719,
|
||||
"invoice": INVOICE
|
||||
"invoice": INVOICE,
|
||||
}
|
||||
|
||||
MESSAGE_WITH_LEFT_CHAT_MEMBER = {}
|
||||
|
|
@ -293,7 +268,7 @@ MESSAGE_WITH_LOCATION = {
|
|||
"from": USER,
|
||||
"chat": CHAT,
|
||||
"date": 1508755473,
|
||||
"location": LOCATION
|
||||
"location": LOCATION,
|
||||
}
|
||||
|
||||
MESSAGE_WITH_MIGRATE_TO_CHAT_ID = {
|
||||
|
|
@ -301,7 +276,7 @@ MESSAGE_WITH_MIGRATE_TO_CHAT_ID = {
|
|||
"from": USER,
|
||||
"chat": CHAT,
|
||||
"date": 1526943253,
|
||||
"migrate_to_chat_id": -1234567890987
|
||||
"migrate_to_chat_id": -1234567890987,
|
||||
}
|
||||
|
||||
MESSAGE_WITH_MIGRATE_FROM_CHAT_ID = {
|
||||
|
|
@ -309,7 +284,7 @@ MESSAGE_WITH_MIGRATE_FROM_CHAT_ID = {
|
|||
"from": USER,
|
||||
"chat": CHAT,
|
||||
"date": 1526943253,
|
||||
"migrate_from_chat_id": -123456789
|
||||
"migrate_from_chat_id": -123456789,
|
||||
}
|
||||
|
||||
MESSAGE_WITH_NEW_CHAT_MEMBERS = {}
|
||||
|
|
@ -324,7 +299,7 @@ MESSAGE_WITH_PHOTO = {
|
|||
"chat": CHAT,
|
||||
"date": 1508825154,
|
||||
"photo": [PHOTO, PHOTO, PHOTO, PHOTO],
|
||||
"caption": "photo description"
|
||||
"caption": "photo description",
|
||||
}
|
||||
|
||||
MESSAGE_WITH_MEDIA_GROUP = {
|
||||
|
|
@ -333,7 +308,7 @@ MESSAGE_WITH_MEDIA_GROUP = {
|
|||
"chat": CHAT,
|
||||
"date": 1522843665,
|
||||
"media_group_id": "12182749320567362",
|
||||
"photo": [PHOTO, PHOTO, PHOTO, PHOTO]
|
||||
"photo": [PHOTO, PHOTO, PHOTO, PHOTO],
|
||||
}
|
||||
|
||||
MESSAGE_WITH_PINNED_MESSAGE = {}
|
||||
|
|
@ -345,7 +320,7 @@ MESSAGE_WITH_STICKER = {
|
|||
"from": USER,
|
||||
"chat": CHAT,
|
||||
"date": 1508771450,
|
||||
"sticker": STICKER
|
||||
"sticker": STICKER,
|
||||
}
|
||||
|
||||
MESSAGE_WITH_SUCCESSFUL_PAYMENT = {
|
||||
|
|
@ -353,7 +328,7 @@ MESSAGE_WITH_SUCCESSFUL_PAYMENT = {
|
|||
"from": USER,
|
||||
"chat": CHAT,
|
||||
"date": 1508761169,
|
||||
"successful_payment": SUCCESSFUL_PAYMENT
|
||||
"successful_payment": SUCCESSFUL_PAYMENT,
|
||||
}
|
||||
|
||||
MESSAGE_WITH_SUPERGROUP_CHAT_CREATED = {}
|
||||
|
|
@ -364,7 +339,7 @@ MESSAGE_WITH_VENUE = {
|
|||
"chat": CHAT,
|
||||
"date": 1522849819,
|
||||
"location": LOCATION,
|
||||
"venue": VENUE
|
||||
"venue": VENUE,
|
||||
}
|
||||
|
||||
MESSAGE_WITH_VIDEO = {
|
||||
|
|
@ -373,7 +348,7 @@ MESSAGE_WITH_VIDEO = {
|
|||
"chat": CHAT,
|
||||
"date": 1508756494,
|
||||
"video": VIDEO,
|
||||
"caption": "description"
|
||||
"caption": "description",
|
||||
}
|
||||
|
||||
MESSAGE_WITH_VIDEO_NOTE = {
|
||||
|
|
@ -381,7 +356,7 @@ MESSAGE_WITH_VIDEO_NOTE = {
|
|||
"from": USER,
|
||||
"chat": CHAT,
|
||||
"date": 1522835890,
|
||||
"video_note": VIDEO_NOTE
|
||||
"video_note": VIDEO_NOTE,
|
||||
}
|
||||
|
||||
MESSAGE_WITH_VOICE = {
|
||||
|
|
@ -389,7 +364,7 @@ MESSAGE_WITH_VOICE = {
|
|||
"from": USER,
|
||||
"chat": CHAT,
|
||||
"date": 1508768403,
|
||||
"voice": VOICE
|
||||
"voice": VOICE,
|
||||
}
|
||||
|
||||
PRE_CHECKOUT_QUERY = {
|
||||
|
|
@ -397,7 +372,7 @@ PRE_CHECKOUT_QUERY = {
|
|||
"from": USER,
|
||||
"currency": "USD",
|
||||
"total_amount": 6250,
|
||||
"invoice_payload": "HAPPY FRIDAYS COUPON"
|
||||
"invoice_payload": "HAPPY FRIDAYS COUPON",
|
||||
}
|
||||
|
||||
REPLY_MESSAGE = {
|
||||
|
|
@ -406,37 +381,22 @@ REPLY_MESSAGE = {
|
|||
"chat": CHAT,
|
||||
"date": 1508751866,
|
||||
"reply_to_message": MESSAGE,
|
||||
"text": "Reply to quoted message"
|
||||
"text": "Reply to quoted message",
|
||||
}
|
||||
|
||||
SHIPPING_QUERY = {
|
||||
"id": "262181558684397422",
|
||||
"from": USER,
|
||||
"invoice_payload": "HAPPY FRIDAYS COUPON",
|
||||
"shipping_address": SHIPPING_ADDRESS
|
||||
"shipping_address": SHIPPING_ADDRESS,
|
||||
}
|
||||
|
||||
USER_PROFILE_PHOTOS = {
|
||||
"total_count": 1, "photos": [
|
||||
[PHOTO, PHOTO, PHOTO]
|
||||
]
|
||||
}
|
||||
USER_PROFILE_PHOTOS = {"total_count": 1, "photos": [[PHOTO, PHOTO, PHOTO]]}
|
||||
|
||||
FILE = {
|
||||
"file_id": "XXXYYYZZZ",
|
||||
"file_size": 5254,
|
||||
"file_path": "voice\/file_8"
|
||||
}
|
||||
FILE = {"file_id": "XXXYYYZZZ", "file_size": 5254, "file_path": "voice/file_8"}
|
||||
|
||||
INVITE_LINK = 'https://t.me/joinchat/AbCdEfjKILDADwdd123'
|
||||
INVITE_LINK = "https://t.me/joinchat/AbCdEfjKILDADwdd123"
|
||||
|
||||
UPDATE = {
|
||||
"update_id": 123456789,
|
||||
"message": MESSAGE
|
||||
}
|
||||
UPDATE = {"update_id": 123456789, "message": MESSAGE}
|
||||
|
||||
WEBHOOK_INFO = {
|
||||
"url": "",
|
||||
"has_custom_certificate": False,
|
||||
"pending_update_count": 0
|
||||
}
|
||||
WEBHOOK_INFO = {"url": "", "has_custom_certificate": False, "pending_update_count": 0}
|
||||
|
|
|
|||
|
|
@ -12,28 +12,28 @@ def test_export():
|
|||
|
||||
def test_file_name():
|
||||
assert isinstance(animation.file_name, str)
|
||||
assert animation.file_name == ANIMATION['file_name']
|
||||
assert animation.file_name == ANIMATION["file_name"]
|
||||
|
||||
|
||||
def test_mime_type():
|
||||
assert isinstance(animation.mime_type, str)
|
||||
assert animation.mime_type == ANIMATION['mime_type']
|
||||
assert animation.mime_type == ANIMATION["mime_type"]
|
||||
|
||||
|
||||
def test_file_id():
|
||||
assert isinstance(animation.file_id, str)
|
||||
# assert hash(animation) == ANIMATION['file_id']
|
||||
assert animation.file_id == ANIMATION['file_id']
|
||||
assert animation.file_id == ANIMATION["file_id"]
|
||||
|
||||
|
||||
def test_file_size():
|
||||
assert isinstance(animation.file_size, int)
|
||||
assert animation.file_size == ANIMATION['file_size']
|
||||
assert animation.file_size == ANIMATION["file_size"]
|
||||
|
||||
|
||||
def test_thumb():
|
||||
assert isinstance(animation.thumb, types.PhotoSize)
|
||||
assert animation.thumb.file_id == ANIMATION['thumb']['file_id']
|
||||
assert animation.thumb.width == ANIMATION['thumb']['width']
|
||||
assert animation.thumb.height == ANIMATION['thumb']['height']
|
||||
assert animation.thumb.file_size == ANIMATION['thumb']['file_size']
|
||||
assert animation.thumb.file_id == ANIMATION["thumb"]["file_id"]
|
||||
assert animation.thumb.width == ANIMATION["thumb"]["width"]
|
||||
assert animation.thumb.height == ANIMATION["thumb"]["height"]
|
||||
assert animation.thumb.file_size == ANIMATION["thumb"]["file_size"]
|
||||
|
|
|
|||
|
|
@ -12,35 +12,36 @@ def test_export():
|
|||
|
||||
def test_id():
|
||||
assert isinstance(chat.id, int)
|
||||
assert chat.id == CHAT['id']
|
||||
assert chat.id == CHAT["id"]
|
||||
# assert hash(chat) == CHAT['id']
|
||||
|
||||
|
||||
def test_name():
|
||||
assert isinstance(chat.first_name, str)
|
||||
assert chat.first_name == CHAT['first_name']
|
||||
assert chat.first_name == CHAT["first_name"]
|
||||
|
||||
assert isinstance(chat.last_name, str)
|
||||
assert chat.last_name == CHAT['last_name']
|
||||
assert chat.last_name == CHAT["last_name"]
|
||||
|
||||
assert isinstance(chat.username, str)
|
||||
assert chat.username == CHAT['username']
|
||||
assert chat.username == CHAT["username"]
|
||||
|
||||
|
||||
def test_type():
|
||||
assert isinstance(chat.type, str)
|
||||
assert chat.type == CHAT['type']
|
||||
assert chat.type == CHAT["type"]
|
||||
|
||||
|
||||
def test_chat_types():
|
||||
assert types.ChatType.PRIVATE == 'private'
|
||||
assert types.ChatType.GROUP == 'group'
|
||||
assert types.ChatType.SUPER_GROUP == 'supergroup'
|
||||
assert types.ChatType.CHANNEL == 'channel'
|
||||
assert types.ChatType.PRIVATE == "private"
|
||||
assert types.ChatType.GROUP == "group"
|
||||
assert types.ChatType.SUPER_GROUP == "supergroup"
|
||||
assert types.ChatType.CHANNEL == "channel"
|
||||
|
||||
|
||||
def test_chat_type_filters():
|
||||
from . import test_message
|
||||
|
||||
assert types.ChatType.is_private(test_message.message)
|
||||
assert not types.ChatType.is_group(test_message.message)
|
||||
assert not types.ChatType.is_super_group(test_message.message)
|
||||
|
|
@ -49,13 +50,13 @@ def test_chat_type_filters():
|
|||
|
||||
|
||||
def test_chat_actions():
|
||||
assert types.ChatActions.TYPING == 'typing'
|
||||
assert types.ChatActions.UPLOAD_PHOTO == 'upload_photo'
|
||||
assert types.ChatActions.RECORD_VIDEO == 'record_video'
|
||||
assert types.ChatActions.UPLOAD_VIDEO == 'upload_video'
|
||||
assert types.ChatActions.RECORD_AUDIO == 'record_audio'
|
||||
assert types.ChatActions.UPLOAD_AUDIO == 'upload_audio'
|
||||
assert types.ChatActions.UPLOAD_DOCUMENT == 'upload_document'
|
||||
assert types.ChatActions.FIND_LOCATION == 'find_location'
|
||||
assert types.ChatActions.RECORD_VIDEO_NOTE == 'record_video_note'
|
||||
assert types.ChatActions.UPLOAD_VIDEO_NOTE == 'upload_video_note'
|
||||
assert types.ChatActions.TYPING == "typing"
|
||||
assert types.ChatActions.UPLOAD_PHOTO == "upload_photo"
|
||||
assert types.ChatActions.RECORD_VIDEO == "record_video"
|
||||
assert types.ChatActions.UPLOAD_VIDEO == "upload_video"
|
||||
assert types.ChatActions.RECORD_AUDIO == "record_audio"
|
||||
assert types.ChatActions.UPLOAD_AUDIO == "upload_audio"
|
||||
assert types.ChatActions.UPLOAD_DOCUMENT == "upload_document"
|
||||
assert types.ChatActions.FIND_LOCATION == "find_location"
|
||||
assert types.ChatActions.RECORD_VIDEO_NOTE == "record_video_note"
|
||||
assert types.ChatActions.UPLOAD_VIDEO_NOTE == "upload_video_note"
|
||||
|
|
|
|||
|
|
@ -12,23 +12,23 @@ def test_export():
|
|||
|
||||
def test_file_name():
|
||||
assert isinstance(document.file_name, str)
|
||||
assert document.file_name == DOCUMENT['file_name']
|
||||
assert document.file_name == DOCUMENT["file_name"]
|
||||
|
||||
|
||||
def test_mime_type():
|
||||
assert isinstance(document.mime_type, str)
|
||||
assert document.mime_type == DOCUMENT['mime_type']
|
||||
assert document.mime_type == DOCUMENT["mime_type"]
|
||||
|
||||
|
||||
def test_file_id():
|
||||
assert isinstance(document.file_id, str)
|
||||
# assert hash(document) == DOCUMENT['file_id']
|
||||
assert document.file_id == DOCUMENT['file_id']
|
||||
assert document.file_id == DOCUMENT["file_id"]
|
||||
|
||||
|
||||
def test_file_size():
|
||||
assert isinstance(document.file_size, int)
|
||||
assert document.file_size == DOCUMENT['file_size']
|
||||
assert document.file_size == DOCUMENT["file_size"]
|
||||
|
||||
|
||||
def test_thumb():
|
||||
|
|
|
|||
|
|
@ -12,17 +12,17 @@ def test_export():
|
|||
|
||||
def test_title():
|
||||
assert isinstance(game.title, str)
|
||||
assert game.title == GAME['title']
|
||||
assert game.title == GAME["title"]
|
||||
|
||||
|
||||
def test_description():
|
||||
assert isinstance(game.description, str)
|
||||
assert game.description == GAME['description']
|
||||
assert game.description == GAME["description"]
|
||||
|
||||
|
||||
def test_photo():
|
||||
assert isinstance(game.photo, list)
|
||||
assert len(game.photo) == len(GAME['photo'])
|
||||
assert len(game.photo) == len(GAME["photo"])
|
||||
assert all(map(lambda t: isinstance(t, types.PhotoSize), game.photo))
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -14,26 +14,26 @@ def test_export():
|
|||
|
||||
def test_message_id():
|
||||
# assert hash(message) == MESSAGE['message_id']
|
||||
assert message.message_id == MESSAGE['message_id']
|
||||
assert message['message_id'] == MESSAGE['message_id']
|
||||
assert message.message_id == MESSAGE["message_id"]
|
||||
assert message["message_id"] == MESSAGE["message_id"]
|
||||
|
||||
|
||||
def test_from():
|
||||
assert isinstance(message.from_user, types.User)
|
||||
assert message.from_user == message['from']
|
||||
assert message.from_user == message["from"]
|
||||
|
||||
|
||||
def test_chat():
|
||||
assert isinstance(message.chat, types.Chat)
|
||||
assert message.chat == message['chat']
|
||||
assert message.chat == message["chat"]
|
||||
|
||||
|
||||
def test_date():
|
||||
assert isinstance(message.date, datetime.datetime)
|
||||
assert int(message.date.timestamp()) == MESSAGE['date']
|
||||
assert message.date == message['date']
|
||||
assert int(message.date.timestamp()) == MESSAGE["date"]
|
||||
assert message.date == message["date"]
|
||||
|
||||
|
||||
def test_text():
|
||||
assert message.text == MESSAGE['text']
|
||||
assert message['text'] == MESSAGE['text']
|
||||
assert message.text == MESSAGE["text"]
|
||||
assert message["text"] == MESSAGE["text"]
|
||||
|
|
|
|||
|
|
@ -12,16 +12,16 @@ def test_export():
|
|||
|
||||
def test_file_id():
|
||||
assert isinstance(photo.file_id, str)
|
||||
assert photo.file_id == PHOTO['file_id']
|
||||
assert photo.file_id == PHOTO["file_id"]
|
||||
|
||||
|
||||
def test_file_size():
|
||||
assert isinstance(photo.file_size, int)
|
||||
assert photo.file_size == PHOTO['file_size']
|
||||
assert photo.file_size == PHOTO["file_size"]
|
||||
|
||||
|
||||
def test_size():
|
||||
assert isinstance(photo.width, int)
|
||||
assert isinstance(photo.height, int)
|
||||
assert photo.width == PHOTO['width']
|
||||
assert photo.height == PHOTO['height']
|
||||
assert photo.width == PHOTO["width"]
|
||||
assert photo.height == PHOTO["height"]
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ def test_export():
|
|||
def test_update_id():
|
||||
assert isinstance(update.update_id, int)
|
||||
# assert hash(update) == UPDATE['update_id']
|
||||
assert update.update_id == UPDATE['update_id']
|
||||
assert update.update_id == UPDATE["update_id"]
|
||||
|
||||
|
||||
def test_message():
|
||||
|
|
|
|||
|
|
@ -14,24 +14,24 @@ def test_export():
|
|||
|
||||
def test_id():
|
||||
assert isinstance(user.id, int)
|
||||
assert user.id == USER['id']
|
||||
assert user.id == USER["id"]
|
||||
# assert hash(user) == USER['id']
|
||||
|
||||
|
||||
def test_bot():
|
||||
assert isinstance(user.is_bot, bool)
|
||||
assert user.is_bot == USER['is_bot']
|
||||
assert user.is_bot == USER["is_bot"]
|
||||
|
||||
|
||||
def test_name():
|
||||
assert user.first_name == USER['first_name']
|
||||
assert user.last_name == USER['last_name']
|
||||
assert user.username == USER['username']
|
||||
assert user.first_name == USER["first_name"]
|
||||
assert user.last_name == USER["last_name"]
|
||||
assert user.username == USER["username"]
|
||||
|
||||
|
||||
def test_language_code():
|
||||
assert user.language_code == USER['language_code']
|
||||
assert user.locale == Locale.parse(USER['language_code'], sep='-')
|
||||
assert user.language_code == USER["language_code"]
|
||||
assert user.locale == Locale.parse(USER["language_code"], sep="-")
|
||||
|
||||
|
||||
def test_full_name():
|
||||
|
|
@ -40,8 +40,10 @@ def test_full_name():
|
|||
|
||||
def test_mention():
|
||||
assert user.mention == f"@{USER['username']}"
|
||||
assert user.get_mention('foo', as_html=False) == f"[foo](tg://user?id={USER['id']})"
|
||||
assert user.get_mention('foo', as_html=True) == f"<a href=\"tg://user?id={USER['id']}\">foo</a>"
|
||||
assert user.get_mention("foo", as_html=False) == f"[foo](tg://user?id={USER['id']})"
|
||||
assert (
|
||||
user.get_mention("foo", as_html=True) == f"<a href=\"tg://user?id={USER['id']}\">foo</a>"
|
||||
)
|
||||
|
||||
|
||||
def test_url():
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue