Beispiel #1
0
 def exec_result(self, mgr: CommandsManager):
     return mgr.exec("hello")
Beispiel #2
0
 def test_fallback(self, mgr: CommandsManager):
     assert mgr.exec("hello") == 'Cannot respond to "hello"'
Beispiel #3
0
 def test_exec(self, mgr: CommandsManager):
     assert mgr.exec("hello") is None
Beispiel #4
0
 def test_nothing_passed(self, mgr: CommandsManager):
     with pytest.raises(TypeError):
         mgr.exec("nothing")
Beispiel #5
0
 def test_forgot_kw(self, mgr: CommandsManager):
     with pytest.raises(TypeError):
         mgr.exec("nothing")
Beispiel #6
0
 def test_invoke(self, mgr: CommandsManager, cmd: str):
     assert mgr.exec(cmd) == "hi"
Beispiel #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"
Beispiel #8
0
 def exec_post(self, mgr: CommandsManager):
     thread_execute(lambda: mgr.exec("post"), 2)
Beispiel #9
0
 def test_simple(self, mgr: CommandsManager):
     assert mgr.exec("world") == "world"
Beispiel #10
0
 def test_close_command_not_invokable(
     self, mgr: CommandsManager, close_echo
 ):
     assert mgr.exec("echo hello") == DEFAULT_CONFIG["text_command_closed"]
Beispiel #11
0
 def test_open_command_invokable(self, mgr: CommandsManager, open_hidden):
     assert mgr.exec("hidden treasure") == "Haha! You found treasure"
Beispiel #12
0
 def test_closed_command_closed(self, mgr: CommandsManager):
     assert (
         mgr.exec("hidden treasure")
         == DEFAULT_CONFIG["text_command_closed"]
     )
Beispiel #13
0
 def test_opening_command_work(self, mgr: CommandsManager):
     assert mgr.exec("echo hello") == "Jack says hello"
Beispiel #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"
Beispiel #15
0
 def test_parameter_passed(self, mgr: CommandsManager):
     assert mgr.exec("nothing", user="******") == "Alex"
Beispiel #16
0
 def test_custom_args(self, mgr: CommandsManager):
     result = mgr.exec("hello", message={"source": "source"})
     assert result == "hello, source!"
Beispiel #17
0
 def test_kw_fine(self, mgr: CommandsManager):
     assert mgr.exec("nothing", user=None) == "Here!"
Beispiel #18
0
 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"]
Beispiel #19
0
 def test_invoke(self, mgr: CommandsManager):
     assert "hEllo" in mgr.exec("hello")
Beispiel #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"]