コード例 #1
0
 def _register_standard_commands(self) -> None:
     '''
     Register any standard commands respecting the configuration provided
     '''
     if self.config['registerHelpCommand']:
         # The command function has to be a lambda as we wish to delay
         # execution until all commands have been registered.
         self.add_command("help",
                          lambda: help_command(self),
                          help_text_override="List all available commmands")
コード例 #2
0
ファイル: test_commands.py プロジェクト: fossabot/phial
    def test_help_command(self):
        bot = MagicMock()
        bot.config = {}
        command = MagicMock()

        command._help = "Test description"
        bot.commands = {"test_pattern": command}
        bot.command_names = {"test_pattern": "test"}

        expected_help_text = "*test* - Test description\n"

        help_text = help_command(bot)
        self.assertEqual(help_text, expected_help_text)
コード例 #3
0
ファイル: test_commands.py プロジェクト: fossabot/phial
    def test_help_command_allows_no_help_text(self):
        bot = MagicMock()
        bot.config = {}
        command = MagicMock()

        command._help = None
        bot.commands = {"test_pattern": command}
        bot.command_names = {"test_pattern": "test"}

        expected_help_text = "*test* - \n"

        help_text = help_command(bot)
        self.assertEqual(help_text, expected_help_text)
コード例 #4
0
ファイル: test_commands.py プロジェクト: fossabot/phial
    def test_help_command_strips_whitespace(self):
        bot = MagicMock()
        command = MagicMock()

        command._help = "\n     Test description     \n"

        bot.commands = {"test_pattern": command}
        bot.command_names = {"test_pattern": "test"}
        bot.config = {'baseHelpText': "Base text"}

        expected_help_text = "Base text\n*test* - Test description\n"

        help_text = help_command(bot)
        self.assertEqual(help_text, expected_help_text)
コード例 #5
0
ファイル: test_commands.py プロジェクト: fossabot/phial
    def test_help_command_multiple(self):
        bot = MagicMock()
        bot.config = {}
        command = MagicMock()
        command2 = MagicMock()

        command._help = "Test description"
        command2._help = "Test description the second"

        bot.commands = {"test_pattern": command, "test2_pattern": command2}
        bot.command_names = {"test_pattern": "test", "test2_pattern": "test2"}

        expected_help_text = "*test* - Test description\n*test2* - " \
                             + "Test description the second\n"

        help_text = help_command(bot)
        self.assertEqual(help_text, expected_help_text)
コード例 #6
0
ファイル: test_commands.py プロジェクト: fossabot/phial
    def test_help_command_parses_multiline_docstring_correctty(self):
        bot = MagicMock()
        command = MagicMock()

        command._help = """
        Test of multiline
        docstring
        """

        bot.commands = {"test_pattern": command}
        bot.command_names = {"test_pattern": "test"}
        bot.config = {'baseHelpText': "Base text"}

        expected_help_text = "Base text\n*test* - Test of multiline" \
                             + " docstring\n"

        help_text = help_command(bot)
        self.assertEqual(help_text, expected_help_text)