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}))
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}))
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}))
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}))
def test_parse_commandsTabIndent(self): """Commands indented with tabs are recognized. (Tabs? What are we, make?) """ self.assertEqual( [('command', [])], parse_commands('\tcommand', {'command': True}))
def test_parse_commandsTabIndent(self): """Commands indented with tabs are recognized. (Tabs? What are we, make?) """ self.assertEqual([('command', [])], parse_commands('\tcommand', {'command': True}))
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'))
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())]
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()) ]
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'))
def test_parse_commandsEmpty(self): """Empty messages have no commands.""" self.assertEqual([], parse_commands('', {'command': True}))
def test_parse_commandsNoIndent(self): """Commands with no indent are not commands.""" self.assertEqual([], parse_commands('command', {'command': True}))
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}))
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}))
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}))
def test_parse_commandsSpaceIndent(self): """Commands indented with spaces are recognized.""" self.assertEqual( [('command', [])], parse_commands(' command', {'command': True}))
def test_parse_commandsNoIndent(self): """Commands with no indent are not commands.""" self.assertEqual([], parse_commands('command', {'command': True}))
def test_parse_commandsEmpty(self): """Empty messages have no commands.""" self.assertEqual([], parse_commands('', {'command': True}))
def test_parse_commandsSpaceIndent(self): """Commands indented with spaces are recognized.""" self.assertEqual([('command', [])], parse_commands(' command', {'command': True}))
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}))
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}))
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}))