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

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: Add a config flag to enable/disable updating monorail bug. Created 4 years, 1 month 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/findit/waterfall/post_comment_to_bug_pipeline.py ('k') | appengine/findit/waterfall/test_info.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..f30055283beb852e979d60443cccda50cb122b4c
--- /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 import post_comment_to_bug_pipeline
+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 = post_comment_to_bug_pipeline._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 = post_comment_to_bug_pipeline._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 = post_comment_to_bug_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 = post_comment_to_bug_pipeline.PostCommentToBugPipeline()
+ pipeline.run(123, 'comment', ['label'])
+ issue_tracker.assert_has_calls(
+ [mock.call('chromium'),
+ mock.call().getIssue(123)])
« no previous file with comments | « appengine/findit/waterfall/post_comment_to_bug_pipeline.py ('k') | appengine/findit/waterfall/test_info.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698