Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
evgfilim1 committed Nov 14, 2022
1 parent 0c197bc commit 4f6f185
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
12 changes: 6 additions & 6 deletions tests/test_modules/test_commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ async def handler() -> None:
)
)
def test_register(handlers: list[tuple[HandlerT, list[str], bool]]) -> None:
"""Tests register() adds all handlers to pyrogram Client"""
"""Tests register() adds all handlers + help handlers to pyrogram Client"""
# Don't repeat commands between handlers
all_commands = set()
for _, commands, _ in handlers:
Expand All @@ -154,14 +154,14 @@ def test_register(handlers: list[tuple[HandlerT, list[str], bool]]) -> None:
) as mock:
commands.register(fake_client)

# Three handlers will be added: "foo", edited "foo" and "bar".
assert mock.call_count == handler_count
# Four handlers will be added: "foo", edited "foo", "bar", "help" and edited "help".
assert mock.call_count == handler_count + 2


def test_register_root() -> None:
"""Tests register() adds a handler + help handler to pyrogram Client"""
def test_register_with_middlewares() -> None:
"""Tests register() adds a handler + help handler + middlewares to pyrogram Client"""

commands = CommandsModule(root=True)
commands = CommandsModule(ensure_middlewares_registered=True)
fake_client = Client("fake", in_memory=True)

@commands.add("foo")
Expand Down
1 change: 0 additions & 1 deletion userbot/modules/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -496,7 +496,6 @@ def register(self, client: Client) -> None:
)
if self._ensure_middlewares_registered:
# These middlewares are expected by the base module to be registered
# TODO (2022-11-06): flag to disable this behavior
if icon_middleware not in self._middleware:
self.add_middleware(icon_middleware)
if translate_middleware not in self._middleware:
Expand Down

0 comments on commit 4f6f185

Please sign in to comment.