mirror of
https://github.com/aiogram/aiogram.git
synced 2026-04-08 16:37:47 +00:00
fix: use ChatMemberFactory instead of the direct class
This commit is contained in:
parent
36c70577bf
commit
bb2ab6ff63
6 changed files with 9 additions and 9 deletions
|
|
@ -26,10 +26,10 @@ class ChatFactory(factory.Factory):
|
|||
def title(self, n):
|
||||
if self.type is ChatType.CHANNEL:
|
||||
return f"Title #{n}"
|
||||
|
||||
|
||||
def __new__(cls, *args, **kwargs) -> "ChatFactory.Meta.model":
|
||||
"""
|
||||
This is a dirty hack for correct type hints
|
||||
See https://github.com/FactoryBoy/factory_boy/issues/468#issuecomment-505646794
|
||||
"""
|
||||
return super().__new__(*args, **kwargs)
|
||||
return super().__new__(*args, **kwargs)
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ class MessageFactory(factory.Factory):
|
|||
text = factory.Sequence(lambda n: f"Message text #{n}")
|
||||
|
||||
date = factory.LazyFunction(lambda _: datetime.now().toordinal())
|
||||
|
||||
|
||||
def __new__(cls, *args, **kwargs) -> "MessageFactory.Meta.model":
|
||||
"""
|
||||
This is a dirty hack for correct type hints
|
||||
|
|
|
|||
|
|
@ -17,4 +17,4 @@ class UserFactory(factory.Factory):
|
|||
This is a dirty hack for correct type hints
|
||||
See https://github.com/FactoryBoy/factory_boy/issues/468#issuecomment-505646794
|
||||
"""
|
||||
return super().__new__(*args, **kwargs)
|
||||
return super().__new__(*args, **kwargs)
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ class TestGetChatAdministrators:
|
|||
@pytest.mark.asyncio
|
||||
async def test_method(self, bot: MockedBot):
|
||||
prepare_result = bot.add_result_for(
|
||||
GetChatAdministrators, ok=True, result=[ChatMemberFactory(status="creator")],
|
||||
GetChatAdministrators, ok=True, result=[ChatMemberFactory(status="creator")]
|
||||
)
|
||||
|
||||
response: List[ChatMember] = await GetChatAdministrators(chat_id=-42)
|
||||
|
|
@ -23,7 +23,7 @@ class TestGetChatAdministrators:
|
|||
@pytest.mark.asyncio
|
||||
async def test_bot_method(self, bot: MockedBot):
|
||||
prepare_result = bot.add_result_for(
|
||||
GetChatAdministrators, ok=True, result=[ChatMemberFactory(status="creator")],
|
||||
GetChatAdministrators, ok=True, result=[ChatMemberFactory(status="creator")]
|
||||
)
|
||||
response: List[ChatMember] = await bot.get_chat_administrators(chat_id=-42)
|
||||
request: Request = bot.get_request()
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ class TestGetChatMember:
|
|||
@pytest.mark.asyncio
|
||||
async def test_method(self, bot: MockedBot):
|
||||
prepare_result = bot.add_result_for(
|
||||
GetChatMember, ok=True, result=ChatMemberFactory(status="creator"),
|
||||
GetChatMember, ok=True, result=ChatMemberFactory(status="creator")
|
||||
)
|
||||
|
||||
response: ChatMember = await GetChatMember(chat_id=-42, user_id=42)
|
||||
|
|
@ -22,7 +22,7 @@ class TestGetChatMember:
|
|||
@pytest.mark.asyncio
|
||||
async def test_bot_method(self, bot: MockedBot):
|
||||
prepare_result = bot.add_result_for(
|
||||
GetChatMember, ok=True, result=ChatMemberFactory(status="creator"),
|
||||
GetChatMember, ok=True, result=ChatMemberFactory(status="creator")
|
||||
)
|
||||
|
||||
response: ChatMember = await bot.get_chat_member(chat_id=-42, user_id=42)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue