Dev 3.x api 5.4 (#744)

* Re-generate API

* Added new modules

* Added handling new event type and approve/decline aliases for ChatJoinRequest

* Fixed code-coverage

* Bump API version

* Added patch-notes
This commit is contained in:
Alex Root Junior 2021-11-08 02:37:37 +02:00 committed by GitHub
parent 3ad16be507
commit 9b43a33b7f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
99 changed files with 631 additions and 199 deletions

View file

@ -0,0 +1,30 @@
import pytest
from aiogram.methods import ApproveChatJoinRequest, Request
from tests.mocked_bot import MockedBot
class TestApproveChatJoinRequest:
@pytest.mark.asyncio
async def test_method(self, bot: MockedBot):
prepare_result = bot.add_result_for(ApproveChatJoinRequest, ok=True, result=True)
response: bool = await ApproveChatJoinRequest(
chat_id=-42,
user_id=42,
)
request: Request = bot.get_request()
assert request.method == "approveChatJoinRequest"
assert response == prepare_result.result
@pytest.mark.asyncio
async def test_bot_method(self, bot: MockedBot):
prepare_result = bot.add_result_for(ApproveChatJoinRequest, ok=True, result=None)
response: bool = await bot.approve_chat_join_request(
chat_id=-42,
user_id=42,
)
request: Request = bot.get_request()
assert request.method == "approveChatJoinRequest"
assert response == prepare_result.result

View file

@ -17,6 +17,7 @@ class TestCreateChatInviteLink:
creator=User(id=42, is_bot=False, first_name="User"),
is_primary=False,
is_revoked=False,
creates_join_request=False,
),
)
@ -37,6 +38,7 @@ class TestCreateChatInviteLink:
creator=User(id=42, is_bot=False, first_name="User"),
is_primary=False,
is_revoked=False,
creates_join_request=False,
),
)

View file

@ -0,0 +1,30 @@
import pytest
from aiogram.methods import DeclineChatJoinRequest, Request
from tests.mocked_bot import MockedBot
class TestDeclineChatJoinRequest:
@pytest.mark.asyncio
async def test_method(self, bot: MockedBot):
prepare_result = bot.add_result_for(DeclineChatJoinRequest, ok=True, result=True)
response: bool = await DeclineChatJoinRequest(
chat_id=-42,
user_id=42,
)
request: Request = bot.get_request()
assert request.method == "declineChatJoinRequest"
assert response == prepare_result.result
@pytest.mark.asyncio
async def test_bot_method(self, bot: MockedBot):
prepare_result = bot.add_result_for(DeclineChatJoinRequest, ok=True, result=True)
response: bool = await bot.decline_chat_join_request(
chat_id=-42,
user_id=42,
)
request: Request = bot.get_request()
assert request.method == "declineChatJoinRequest"
assert response == prepare_result.result

View file

@ -17,6 +17,7 @@ class TestEditChatInviteLink:
creator=User(id=42, is_bot=False, first_name="User"),
is_primary=False,
is_revoked=False,
creates_join_request=False,
),
)
@ -25,7 +26,6 @@ class TestEditChatInviteLink:
)
request: Request = bot.get_request()
assert request.method == "editChatInviteLink"
# assert request.data == {}
assert response == prepare_result.result
async def test_bot_method(self, bot: MockedBot):
@ -37,6 +37,7 @@ class TestEditChatInviteLink:
creator=User(id=42, is_bot=False, first_name="User"),
is_primary=False,
is_revoked=False,
creates_join_request=False,
),
)
@ -45,5 +46,4 @@ class TestEditChatInviteLink:
)
request: Request = bot.get_request()
assert request.method == "editChatInviteLink"
# assert request.data == {}
assert response == prepare_result.result

View file

@ -17,6 +17,7 @@ class TestRevokeChatInviteLink:
creator=User(id=42, is_bot=False, first_name="User"),
is_primary=False,
is_revoked=True,
creates_join_request=False,
),
)
@ -26,7 +27,6 @@ class TestRevokeChatInviteLink:
)
request: Request = bot.get_request()
assert request.method == "revokeChatInviteLink"
# assert request.data == {}
assert response == prepare_result.result
async def test_bot_method(self, bot: MockedBot):
@ -38,6 +38,7 @@ class TestRevokeChatInviteLink:
creator=User(id=42, is_bot=False, first_name="User"),
is_primary=False,
is_revoked=True,
creates_join_request=False,
),
)
@ -47,5 +48,4 @@ class TestRevokeChatInviteLink:
)
request: Request = bot.get_request()
assert request.method == "revokeChatInviteLink"
# assert request.data == {}
assert response == prepare_result.result