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

Unified Diff: appengine/findit/waterfall/test/post_comment_to_bug_pipeline_test.py

Issue 2438673004: [Findit] Post analysis results of flakes to bug filed by chromium-try-flakes. (Closed)
Patch Set: Created 4 years, 2 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
Index: appengine/findit/waterfall/test/post_comment_to_bug_pipeline_test.py
diff --git a/appengine/findit/waterfall/test/post_comment_to_bug_pipeline_test.py b/appengine/findit/waterfall/test/post_comment_to_bug_pipeline_test.py
new file mode 100644
index 0000000000000000000000000000000000000000..4617a55006c4affb593c3ee92717651903555dcb
--- /dev/null
+++ b/appengine/findit/waterfall/test/post_comment_to_bug_pipeline_test.py
@@ -0,0 +1,62 @@
+# Copyright 2016 The Chromium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+import mock
+
+from issue_tracker import Issue
+
+from waterfall.post_comment_to_bug_pipeline import PostCommentToBugPipeline
+from waterfall.test import wf_testcase
+
+
+class PostCommentToBugPipelineTest(wf_testcase.WaterfallTestCase):
+
+ def testGetIssueWithoutMergeInto(self):
+ issue_tracker = mock.Mock()
+ expected_issue = Issue({})
+ issue_tracker.getIssue.return_value = expected_issue
+
+ issue = PostCommentToBugPipeline._GetIssue(123, issue_tracker)
+ self.assertEqual(expected_issue, issue)
+ issue_tracker.assert_has_calls([mock.call.getIssue(123)])
+
+ def testGetIssueWithMergeInto(self):
+ issue_tracker = mock.Mock()
+ expected_issue = Issue({})
+ issue_tracker.getIssue.side_effect = [
+ Issue({'mergedInto': {'issueId': 234}}),
+ Issue({'mergedInto': {'issueId': 345}}),
+ expected_issue,
+ ]
+
+ issue = PostCommentToBugPipeline._GetIssue(123, issue_tracker)
+ self.assertEqual(expected_issue, issue)
+ issue_tracker.assert_has_calls(
+ [mock.call.getIssue(123), mock.call.getIssue(234),
+ mock.call.getIssue(345)])
+
+ @mock.patch('waterfall.post_comment_to_bug_pipeline.IssueTrackerAPI')
+ def testPostCommentToBug(self, issue_tracker):
+ dummy_issue = Issue({})
+ mocked_instance = mock.Mock()
+ mocked_instance.getIssue.return_value = dummy_issue
+ issue_tracker.return_value = mocked_instance
+ pipeline = PostCommentToBugPipeline()
+ pipeline.run(123, 'comment', ['label'])
+ issue_tracker.assert_has_calls(
+ [mock.call('chromium'),
+ mock.call().getIssue(123),
+ mock.call().update(dummy_issue, 'comment', send_email=True)])
+ self.assertEqual(['label'], dummy_issue.labels)
+
+ @mock.patch('waterfall.post_comment_to_bug_pipeline.IssueTrackerAPI')
+ def testPostCommentToBugWhenDeleted(self, issue_tracker):
+ mocked_instance = mock.Mock()
+ mocked_instance.getIssue.return_value = None
+ issue_tracker.return_value = mocked_instance
+ pipeline = PostCommentToBugPipeline()
+ pipeline.run(123, 'comment', ['label'])
+ issue_tracker.assert_has_calls(
+ [mock.call('chromium'),
+ mock.call().getIssue(123)])

Powered by Google App Engine
This is Rietveld 408576698