From bc1a55f21fb5fb115da17c68bdbbbe4e6c551926 Mon Sep 17 00:00:00 2001 From: chewingbever Date: Wed, 26 Aug 2020 14:12:58 +0200 Subject: [PATCH] Added commands order test --- tests/module_tester.py | 10 +++++++++- tests/test_module.py | 11 ++++++++++- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/tests/module_tester.py b/tests/module_tester.py index cc66ca2..69ae5b5 100644 --- a/tests/module_tester.py +++ b/tests/module_tester.py @@ -1,9 +1,17 @@ -from frank import Module, command, default, daemon +from frank import Module, command, default, daemon, regex_command class ModuleTester(Module): PREFIX = 'tester' + @regex_command('pat') + async def regex1(pregix, cmd, author, channel, mid): + pass + + @regex_command('pat2') + async def regex2(pregix, cmd, author, channel, mid): + pass + @command('test') async def test(cmd, author, channel, mid): pass diff --git a/tests/test_module.py b/tests/test_module.py index 75aab8c..adf040e 100644 --- a/tests/test_module.py +++ b/tests/test_module.py @@ -1,5 +1,5 @@ from .module_tester import ModuleTester -from frank import Default, Daemon, Command +from frank import Default, Daemon, Command, RegexCommand from frank.module.exceptions import InvalidCommand import pytest @@ -39,3 +39,12 @@ def test_match(): assert test_mod.match('tester') assert not test_mod.match('testerrr') + + +def test_commands_order(): + test_mod = ModuleTester(None) + + types = [Command, RegexCommand, RegexCommand] + + assert all((isinstance(cmd, obj_type) + for cmd, obj_type in zip(test_mod.commands, types)))