コード例 #1
0
 def exec_result(self, mgr: CommandsManager):
     return mgr.exec("hello")
コード例 #2
0
 def test_fallback(self, mgr: CommandsManager):
     assert mgr.exec("hello") == 'Cannot respond to "hello"'
コード例 #3
0
 def test_exec(self, mgr: CommandsManager):
     assert mgr.exec("hello") is None
コード例 #4
0
 def test_nothing_passed(self, mgr: CommandsManager):
     with pytest.raises(TypeError):
         mgr.exec("nothing")
コード例 #5
0
 def test_forgot_kw(self, mgr: CommandsManager):
     with pytest.raises(TypeError):
         mgr.exec("nothing")
コード例 #6
0
 def test_invoke(self, mgr: CommandsManager, cmd: str):
     assert mgr.exec(cmd) == "hi"
コード例 #7
0
 def test_status(self, mgr: CommandsManager):
     assert mgr.exec("echo") == DEFAULT_CONFIG["text_command_closed"]
     assert mgr.exec("hidden treasure") == "Haha! You found treasure"
コード例 #8
0
 def exec_post(self, mgr: CommandsManager):
     thread_execute(lambda: mgr.exec("post"), 2)
コード例 #9
0
ファイル: test_basic.py プロジェクト: AllanChain/command4bot
 def test_simple(self, mgr: CommandsManager):
     assert mgr.exec("world") == "world"
コード例 #10
0
 def test_close_command_not_invokable(
     self, mgr: CommandsManager, close_echo
 ):
     assert mgr.exec("echo hello") == DEFAULT_CONFIG["text_command_closed"]
コード例 #11
0
 def test_open_command_invokable(self, mgr: CommandsManager, open_hidden):
     assert mgr.exec("hidden treasure") == "Haha! You found treasure"
コード例 #12
0
 def test_closed_command_closed(self, mgr: CommandsManager):
     assert (
         mgr.exec("hidden treasure")
         == DEFAULT_CONFIG["text_command_closed"]
     )
コード例 #13
0
 def test_opening_command_work(self, mgr: CommandsManager):
     assert mgr.exec("echo hello") == "Jack says hello"
コード例 #14
0
 def test_status(self, mgr: CommandsManager):
     assert mgr.exec("echo hello") == "Jack says hello"
     assert mgr.exec("hidden treasure") == "Haha! You found treasure"
コード例 #15
0
 def test_parameter_passed(self, mgr: CommandsManager):
     assert mgr.exec("nothing", user="******") == "Alex"
コード例 #16
0
ファイル: test_basic.py プロジェクト: AllanChain/command4bot
 def test_custom_args(self, mgr: CommandsManager):
     result = mgr.exec("hello", message={"source": "source"})
     assert result == "hello, source!"
コード例 #17
0
 def test_kw_fine(self, mgr: CommandsManager):
     assert mgr.exec("nothing", user=None) == "Here!"
コード例 #18
0
ファイル: test_basic.py プロジェクト: AllanChain/command4bot
 def test_fallback(self, mgr: CommandsManager):
     "This tests both two types of help and cached fallback"
     assert (mgr.exec("word") == DEFAULT_CONFIG["text_possible_command"] +
             "\n- Say world")
     assert mgr.exec("adflj") == DEFAULT_CONFIG["text_general_response"]
コード例 #19
0
 def test_invoke(self, mgr: CommandsManager):
     assert "hEllo" in mgr.exec("hello")
コード例 #20
0
 def test_default_close(self, mgr: CommandsManager):
     assert mgr.exec("hi") == DEFAULT_CONFIG["text_command_closed"]
     assert mgr.exec("aloha") == DEFAULT_CONFIG["text_command_closed"]