Exemplo n.º 1
0
 def test_parse_commands_optional_colons(self):
     """Colons at the end of commands are accepted and stripped."""
     self.assertEqual([('command', ['arg1', 'arg2'])],
                      parse_commands(' command: arg1 arg2',
                                     {'command': True}))
     self.assertEqual([('command', [])],
                      parse_commands(' command:', {'command': True}))
Exemplo n.º 2
0
 def test_parse_commands_optional_colons(self):
     """Colons at the end of commands are accepted and stripped."""
     self.assertEqual(
         [('command', ['arg1', 'arg2'])],
         parse_commands(' command: arg1 arg2', {'command': True}))
     self.assertEqual(
         [('command', [])],
         parse_commands(' command:', {'command': True}))
Exemplo n.º 3
0
 def test_parse_commandsDone(self):
     """The 'done' pseudo-command halts processing."""
     self.assertEqual([('command', []), ('command', [])],
                      parse_commands(' command\n command',
                                     {'command': True}))
     self.assertEqual([('command', [])],
                      parse_commands(' command\n done\n command',
                                     {'command': True}))
     # done takes no arguments.
     self.assertEqual([('command', []), ('command', [])],
                      parse_commands(' command\n done commands\n command',
                                     {'command': True}))
Exemplo n.º 4
0
 def test_parse_commandsDone(self):
     """The 'done' pseudo-command halts processing."""
     self.assertEqual(
         [('command', []), ('command', [])],
         parse_commands(' command\n command', {'command': True}))
     self.assertEqual(
         [('command', [])],
         parse_commands(' command\n done\n command', {'command': True}))
     # done takes no arguments.
     self.assertEqual(
         [('command', []), ('command', [])],
         parse_commands(
             ' command\n done commands\n command', {'command': True}))
Exemplo n.º 5
0
    def test_parse_commandsTabIndent(self):
        """Commands indented with tabs are recognized.

        (Tabs?  What are we, make?)
        """
        self.assertEqual(
            [('command', [])], parse_commands('\tcommand', {'command': True}))
Exemplo n.º 6
0
    def test_parse_commandsTabIndent(self):
        """Commands indented with tabs are recognized.

        (Tabs?  What are we, make?)
        """
        self.assertEqual([('command', [])],
                         parse_commands('\tcommand', {'command': True}))
Exemplo n.º 7
0
 def getCommands(klass, message_body):
     """Extract the commands from the message body."""
     if message_body is None:
         return []
     commands = [klass.get(name=name, string_args=args) for
                 name, args in parse_commands(message_body,
                                              klass.parsingParameters())]
     return sorted(commands, key=operator.attrgetter('sort_order'))
Exemplo n.º 8
0
 def getCommands(self, signed_msg):
     """Returns a list of all the commands found in the email."""
     content = get_main_body(signed_msg)
     if content is None:
         return []
     return [
         BugEmailCommands.get(name=name, string_args=args) for
         name, args in parse_commands(
             content, BugEmailCommands.parsingParameters())]
Exemplo n.º 9
0
 def getCommands(self, signed_msg):
     """Returns a list of all the commands found in the email."""
     content = get_main_body(signed_msg)
     if content is None:
         return []
     return [
         BugEmailCommands.get(name=name, string_args=args)
         for name, args in parse_commands(
             content, BugEmailCommands.parsingParameters())
     ]
Exemplo n.º 10
0
 def getCommands(klass, message_body):
     """Extract the commands from the message body."""
     if message_body is None:
         return []
     commands = [
         klass.get(name=name, string_args=args)
         for name, args in parse_commands(message_body,
                                          klass.parsingParameters())
     ]
     return sorted(commands, key=operator.attrgetter('sort_order'))
Exemplo n.º 11
0
 def test_parse_commandsEmpty(self):
     """Empty messages have no commands."""
     self.assertEqual([], parse_commands('', {'command': True}))
Exemplo n.º 12
0
 def test_parse_commandsNoIndent(self):
     """Commands with no indent are not commands."""
     self.assertEqual([], parse_commands('command', {'command': True}))
Exemplo n.º 13
0
 def test_parse_commands_args_quoted(self):
     """Commands indented with spaces are recognized."""
     self.assertEqual(
         [('command', ['"arg1', 'arg2"'])],
         parse_commands(' command "arg1 arg2"', {'command': True}))
Exemplo n.º 14
0
 def test_parse_commands_args_uppercase_to_lowercase(self):
     """Commands and args containing uppercase letters are converted to
     lowercase."""
     self.assertEqual(
         [('command', ['arg1', 'arg2'])],
         parse_commands(' comMand Arg1 aRg2', {'command': True}))
Exemplo n.º 15
0
 def test_parse_commands_args_uppercase_unchanged(self):
     """Commands and args containing uppercase letters are not
     converted to lowercase if the flag is False."""
     self.assertEqual(
         [('command', ['Arg1', 'aRg2'])],
         parse_commands(' comMand Arg1 aRg2', {'command': False}))
Exemplo n.º 16
0
 def test_parse_commandsSpaceIndent(self):
     """Commands indented with spaces are recognized."""
     self.assertEqual(
         [('command', [])], parse_commands(' command', {'command': True}))
Exemplo n.º 17
0
 def test_parse_commandsNoIndent(self):
     """Commands with no indent are not commands."""
     self.assertEqual([], parse_commands('command',  {'command': True}))
Exemplo n.º 18
0
 def test_parse_commandsEmpty(self):
     """Empty messages have no commands."""
     self.assertEqual([], parse_commands('', {'command': True}))
Exemplo n.º 19
0
 def test_parse_commandsSpaceIndent(self):
     """Commands indented with spaces are recognized."""
     self.assertEqual([('command', [])],
                      parse_commands(' command', {'command': True}))
Exemplo n.º 20
0
 def test_parse_commands_args_uppercase_unchanged(self):
     """Commands and args containing uppercase letters are not
     converted to lowercase if the flag is False."""
     self.assertEqual([('command', ['Arg1', 'aRg2'])],
                      parse_commands(' comMand Arg1 aRg2',
                                     {'command': False}))
Exemplo n.º 21
0
 def test_parse_commands_args_uppercase_to_lowercase(self):
     """Commands and args containing uppercase letters are converted to
     lowercase."""
     self.assertEqual([('command', ['arg1', 'arg2'])],
                      parse_commands(' comMand Arg1 aRg2',
                                     {'command': True}))
Exemplo n.º 22
0
 def test_parse_commands_args_quoted(self):
     """Commands indented with spaces are recognized."""
     self.assertEqual([('command', ['"arg1', 'arg2"'])],
                      parse_commands(' command "arg1 arg2"',
                                     {'command': True}))