def test_execute_bug_id_new(self): user = self.factory.makePerson() login_person(user) message = self.factory.makeSignedMessage( body='borked\n affects fnord', subject='title borked', to_address='*****@*****.**') filealias = self.factory.makeLibraryFileAlias() command = BugEmailCommand('bug', ['new']) params, event = command.execute(message, filealias) self.assertEqual(None, event) self.assertEqual(user, params.owner) self.assertEqual('title borked', params.title) self.assertEqual(message['Message-Id'], params.msg.rfc822msgid)
def test_execute_bug_id_not_found(self): command = BugEmailCommand('bug', ['9999999']) error = self.assertRaises(EmailProcessingError, command.execute, None, None) message = str(error).split('\n') self.assertEqual("There is no such bug in Launchpad: 9999999", message[0])
def test_execute_bug_id_wrong_type(self): command = BugEmailCommand('bug', ['nickname']) error = self.assertRaises(EmailProcessingError, command.execute, None, None) message = str(error).split('\n') self.assertEqual("The 'bug' command expects either 'new' or a bug id.", message[0])
def test_execute_bug_id(self): bug = self.factory.makeBug() command = BugEmailCommand('bug', [str(bug.id)]) self.assertEqual((bug, None), command.execute(None, None))