mirror of
https://github.com/aiogram/aiogram.git
synced 2026-04-08 16:37:47 +00:00
Merge remote-tracking branch 'origin/dev-3.x' into dev-3.x
# Conflicts: # README.md # README.rst # aiogram/__init__.py # aiogram/bot/bot.py # aiogram/contrib/fsm_storage/redis.py # aiogram/contrib/middlewares/logging.py # aiogram/dispatcher/dispatcher.py # aiogram/dispatcher/filters/__init__.py # aiogram/dispatcher/filters/builtin.py # aiogram/dispatcher/filters/filters.py # aiogram/dispatcher/filters/state.py # aiogram/dispatcher/handler.py # aiogram/dispatcher/webhook.py # aiogram/types/base.py # aiogram/types/chat.py # aiogram/types/chat_member.py # aiogram/types/input_media.py # aiogram/types/message.py # aiogram/utils/callback_data.py # aiogram/utils/deprecated.py # aiogram/utils/exceptions.py # aiogram/utils/executor.py # aiogram/utils/helper.py # aiogram/utils/json.py # aiogram/utils/mixins.py # aiogram/utils/payload.py # dev_requirements.txt # docs/source/index.rst # examples/callback_data_factory.py # examples/check_user_language.py # examples/echo_bot.py # examples/finite_state_machine_example.py # examples/i18n_example.py # examples/inline_bot.py # examples/media_group.py # examples/middleware_and_antiflood.py # examples/payments.py # examples/proxy_and_emojize.py # examples/regexp_commands_filter_example.py # examples/throtling_example.py # examples/webhook_example.py # examples/webhook_example_2.py # setup.py # tests/test_bot.py # tests/test_token.py # tests/types/dataset.py
This commit is contained in:
commit
87393f2475
98 changed files with 5048 additions and 4854 deletions
|
|
@ -47,7 +47,11 @@ CHAT_MEMBER = {
|
|||
"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",
|
||||
|
|
@ -64,17 +68,42 @@ ANIMATION = {
|
|||
"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",
|
||||
|
|
@ -86,15 +115,18 @@ GAME = {
|
|||
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,
|
||||
}
|
||||
|
||||
LOCATION = {"latitude": 50.693416, "longitude": 30.624605}
|
||||
LOCATION = {
|
||||
"latitude": 50.693416,
|
||||
"longitude": 30.624605,
|
||||
}
|
||||
|
||||
VENUE = {
|
||||
"location": LOCATION,
|
||||
|
|
@ -121,7 +153,7 @@ STICKER = {
|
|||
"file_id": "AAbbCCddEEffGGhh1234567890",
|
||||
"file_size": 1234,
|
||||
"width": 128,
|
||||
"height": 128,
|
||||
"height": 128
|
||||
},
|
||||
"file_id": "AAbbCCddEEffGGhh1234567890",
|
||||
"file_size": 12345,
|
||||
|
|
@ -186,15 +218,8 @@ 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 = {}
|
||||
|
|
@ -391,12 +416,27 @@ SHIPPING_QUERY = {
|
|||
"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,
|
||||
}
|
||||
|
|
|
|||
77
tests/types/test_chat_member.py
Normal file
77
tests/types/test_chat_member.py
Normal file
|
|
@ -0,0 +1,77 @@
|
|||
from aiogram import types
|
||||
from .dataset import CHAT_MEMBER
|
||||
|
||||
chat_member = types.ChatMember(**CHAT_MEMBER)
|
||||
|
||||
|
||||
def test_export():
|
||||
exported = chat_member.to_python()
|
||||
assert isinstance(exported, dict)
|
||||
assert exported == CHAT_MEMBER
|
||||
|
||||
|
||||
def test_user():
|
||||
assert isinstance(chat_member.user, types.User)
|
||||
|
||||
|
||||
def test_status():
|
||||
assert isinstance(chat_member.status, str)
|
||||
assert chat_member.status == CHAT_MEMBER['status']
|
||||
|
||||
|
||||
def test_privileges():
|
||||
assert isinstance(chat_member.can_be_edited, bool)
|
||||
assert chat_member.can_be_edited == CHAT_MEMBER['can_be_edited']
|
||||
|
||||
assert isinstance(chat_member.can_change_info, bool)
|
||||
assert chat_member.can_change_info == CHAT_MEMBER['can_change_info']
|
||||
|
||||
assert isinstance(chat_member.can_delete_messages, bool)
|
||||
assert chat_member.can_delete_messages == CHAT_MEMBER['can_delete_messages']
|
||||
|
||||
assert isinstance(chat_member.can_invite_users, bool)
|
||||
assert chat_member.can_invite_users == CHAT_MEMBER['can_invite_users']
|
||||
|
||||
assert isinstance(chat_member.can_restrict_members, bool)
|
||||
assert chat_member.can_restrict_members == CHAT_MEMBER['can_restrict_members']
|
||||
|
||||
assert isinstance(chat_member.can_pin_messages, bool)
|
||||
assert chat_member.can_pin_messages == CHAT_MEMBER['can_pin_messages']
|
||||
|
||||
assert isinstance(chat_member.can_promote_members, bool)
|
||||
assert chat_member.can_promote_members == CHAT_MEMBER['can_promote_members']
|
||||
|
||||
|
||||
def test_int():
|
||||
assert int(chat_member) == chat_member.user.id
|
||||
assert isinstance(int(chat_member), int)
|
||||
|
||||
|
||||
def test_chat_member_status():
|
||||
assert types.ChatMemberStatus.CREATOR == 'creator'
|
||||
assert types.ChatMemberStatus.ADMINISTRATOR == 'administrator'
|
||||
assert types.ChatMemberStatus.MEMBER == 'member'
|
||||
assert types.ChatMemberStatus.RESTRICTED == 'restricted'
|
||||
assert types.ChatMemberStatus.LEFT == 'left'
|
||||
assert types.ChatMemberStatus.KICKED == 'kicked'
|
||||
|
||||
|
||||
def test_chat_member_status_filters():
|
||||
assert types.ChatMemberStatus.is_chat_admin(chat_member.status)
|
||||
assert types.ChatMemberStatus.is_chat_member(chat_member.status)
|
||||
|
||||
assert types.ChatMemberStatus.is_chat_admin(types.ChatMemberStatus.CREATOR)
|
||||
assert types.ChatMemberStatus.is_chat_admin(types.ChatMemberStatus.ADMINISTRATOR)
|
||||
|
||||
assert types.ChatMemberStatus.is_chat_member(types.ChatMemberStatus.CREATOR)
|
||||
assert types.ChatMemberStatus.is_chat_member(types.ChatMemberStatus.ADMINISTRATOR)
|
||||
assert types.ChatMemberStatus.is_chat_member(types.ChatMemberStatus.MEMBER)
|
||||
assert types.ChatMemberStatus.is_chat_member(types.ChatMemberStatus.RESTRICTED)
|
||||
|
||||
assert not types.ChatMemberStatus.is_chat_member(types.ChatMemberStatus.LEFT)
|
||||
assert not types.ChatMemberStatus.is_chat_member(types.ChatMemberStatus.KICKED)
|
||||
|
||||
|
||||
def test_chat_member_filters():
|
||||
assert chat_member.is_chat_admin()
|
||||
assert chat_member.is_chat_member()
|
||||
Loading…
Add table
Add a link
Reference in a new issue