def test_reviewer_command(self): # Check that the add review command is correctly created. [command] = CodeEmailCommands.getCommands( " reviewer [email protected] db") self.assertIsInstance(command, AddReviewerEmailCommand) self.assertEqual('reviewer', command.name) self.assertEqual(['*****@*****.**', 'db'], command.string_args)
def test_vote_commands_come_first(self): # Vote commands come before either status or reviewer commands. message_body = """ status approved vote approve db """ vote_command, status_command = CodeEmailCommands.getCommands( message_body) self.assertIsInstance(vote_command, VoteEmailCommand) self.assertIsInstance(status_command, UpdateStatusEmailCommand) message_body = """ reviewer foo.bar vote reject """ vote_command, reviewer_command = CodeEmailCommands.getCommands( message_body) self.assertIsInstance(vote_command, VoteEmailCommand) self.assertIsInstance(reviewer_command, AddReviewerEmailCommand)
def test_merge_command(self): # Merge is an alias for the status command. [command] = CodeEmailCommands.getCommands(" merge approved") self.assertIsInstance(command, UpdateStatusEmailCommand) self.assertEqual('merge', command.name) self.assertEqual(['approved'], command.string_args)
def test_status_command(self): # Check that the update status command is correctly created. [command] = CodeEmailCommands.getCommands(" status approved") self.assertIsInstance(command, UpdateStatusEmailCommand) self.assertEqual('status', command.name) self.assertEqual(['approved'], command.string_args)
def test_review_as_vote_command(self): # Check that the vote command is correctly created. [command] = CodeEmailCommands.getCommands(" review approve tag me") self.assertIsInstance(command, VoteEmailCommand) self.assertEqual('review', command.name) self.assertEqual(['approve', 'tag', 'me'], command.string_args)
def test_no_message(self): # Null in, empty list out. self.assertEqual([], CodeEmailCommands.getCommands(None))
def test_ignored_commands(self): # Check that other "commands" are not created. self.assertEqual([], CodeEmailCommands.getCommands( " not-a-command\n spam"))