Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2226)

Unified Diff: appengine/monorail/features/test/commitlogcommands_test.py

Issue 1868553004: Open Source Monorail (Closed) Base URL: https://chromium.googlesource.com/infra/infra.git@master
Patch Set: Rebase Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « appengine/monorail/features/test/commands_test.py ('k') | appengine/monorail/features/test/cues_test.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: appengine/monorail/features/test/commitlogcommands_test.py
diff --git a/appengine/monorail/features/test/commitlogcommands_test.py b/appengine/monorail/features/test/commitlogcommands_test.py
new file mode 100644
index 0000000000000000000000000000000000000000..4c43cd4e2517738ced654e2d76708db5e7ddccfd
--- /dev/null
+++ b/appengine/monorail/features/test/commitlogcommands_test.py
@@ -0,0 +1,96 @@
+# Copyright 2016 The Chromium Authors. All rights reserved.
+# Use of this source code is govered by a BSD-style
+# license that can be found in the LICENSE file or at
+# https://developers.google.com/open-source/licenses/bsd
+
+"""Unittests for monorail.features.commitlogcommands."""
+
+import unittest
+
+import mox
+
+from features import commitlogcommands
+from features import notify
+from proto import tracker_pb2
+from services import service_manager
+from testing import fake
+from testing import testing_helpers
+
+
+class InboundEmailTest(unittest.TestCase):
+
+ def setUp(self):
+ self.cnxn = 'fake cnxn'
+ self.services = service_manager.Services(
+ issue=fake.IssueService(),
+ project=fake.ProjectService(),
+ config=fake.ConfigService())
+
+ self.project = self.services.project.TestAddProject(
+ 'proj', project_id=987, process_inbound_email=True)
+ self.issue = tracker_pb2.Issue()
+ self.issue.project_id = 987
+ self.issue.summary = 'summary'
+ self.issue.status = 'Assigned'
+ self.services.issue.TestAddIssue(self.issue)
+
+ self.uia = commitlogcommands.UpdateIssueAction(self.issue.local_id)
+ self.mox = mox.Mox()
+
+ def tearDown(self):
+ self.mox.UnsetStubs()
+ self.mox.ResetAll()
+
+ def testParse_StripQuotedLines(self):
+ self.uia.Parse(self.cnxn, self.project.project_name, 101,
+ ['summary:something', '> line 1', 'line 2'], self.services,
+ hostport=80, strip_quoted_lines=True)
+ self.assertEquals('line 2', self.uia.description)
+ self.assertEquals('summary:something\n> line 1\nline 2',
+ self.uia.inbound_message)
+
+ def testParse_NoStripQuotedLines(self):
+ self.uia.Parse(self.cnxn, self.project.project_name, 101,
+ ['summary:something', '> line 1', 'line 2'], self.services,
+ hostport=80)
+ self.assertEquals('> line 1\nline 2', self.uia.description)
+ self.assertIsNone(self.uia.inbound_message)
+
+ def setupAndCallRun(self, allow_edit):
+ comments = ['comment 1', 'comment 2', 'comment 3']
+
+ self.mox.StubOutWithMock(self.services.issue, 'GetCommentsForIssue')
+ self.services.issue.GetCommentsForIssue(
+ self.cnxn, self.issue.issue_id).AndReturn(comments)
+ self.mox.StubOutWithMock(notify, 'PrepareAndSendIssueChangeNotification')
+ notify.PrepareAndSendIssueChangeNotification(
+ self.project.project_id, self.issue.local_id, 80, 101,
+ len(comments) - 1, old_owner_id=self.issue.owner_id)
+ self.mox.ReplayAll()
+
+ self.uia.Parse(self.cnxn, self.project.project_name, 101,
+ ['summary:something', 'status:New', '> line 1', '> line 2'],
+ self.services, hostport=80)
+ self.uia.Run(self.cnxn, self.services, allow_edit=allow_edit)
+ self.mox.VerifyAll()
+
+ def testRun_AllowEdit(self):
+ self.setupAndCallRun(allow_edit=True)
+
+ self.assertEquals('> line 1\n> line 2', self.uia.description)
+ # Assert that ammendments were made to the issue.
+ self.assertEquals('something', self.issue.summary)
+ self.assertEquals('New', self.issue.status)
+
+
+ def testRun_NoAllowEdit(self):
+ self.setupAndCallRun(allow_edit=False)
+
+ self.assertEquals('> line 1\n> line 2', self.uia.description)
+ # Assert that ammendments were *not* made to the issue.
+ self.assertEquals('summary', self.issue.summary)
+ self.assertEquals('Assigned', self.issue.status)
+
+
+if __name__ == '__main__':
+ unittest.main()
« no previous file with comments | « appengine/monorail/features/test/commands_test.py ('k') | appengine/monorail/features/test/cues_test.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698