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

Side by Side 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 unified diff | Download patch
OLDNEW
(Empty)
1 # Copyright 2016 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file.
4
5 import mock
6
7 from issue_tracker import Issue
8
9 from waterfall import post_comment_to_bug_pipeline
10 from waterfall.test import wf_testcase
11
12
13 class PostCommentToBugPipelineTest(wf_testcase.WaterfallTestCase):
14
15 def testGetIssueWithoutMergeInto(self):
16 issue_tracker = mock.Mock()
17 expected_issue = Issue({})
18 issue_tracker.getIssue.return_value = expected_issue
19
20 issue = post_comment_to_bug_pipeline._GetIssue(123, issue_tracker)
21 self.assertEqual(expected_issue, issue)
22 issue_tracker.assert_has_calls([mock.call.getIssue(123)])
23
24 def testGetIssueWithMergeInto(self):
25 issue_tracker = mock.Mock()
26 expected_issue = Issue({})
27 issue_tracker.getIssue.side_effect = [
28 Issue({'mergedInto': {'issueId': 234}}),
29 Issue({'mergedInto': {'issueId': 345}}),
30 expected_issue,
31 ]
32
33 issue = post_comment_to_bug_pipeline._GetIssue(123, issue_tracker)
34 self.assertEqual(expected_issue, issue)
35 issue_tracker.assert_has_calls(
36 [mock.call.getIssue(123), mock.call.getIssue(234),
37 mock.call.getIssue(345)])
38
39 @mock.patch('waterfall.post_comment_to_bug_pipeline.IssueTrackerAPI')
40 def testPostCommentToBug(self, issue_tracker):
41 dummy_issue = Issue({})
42 mocked_instance = mock.Mock()
43 mocked_instance.getIssue.return_value = dummy_issue
44 issue_tracker.return_value = mocked_instance
45 pipeline = post_comment_to_bug_pipeline.PostCommentToBugPipeline()
46 pipeline.run(123, 'comment', ['label'])
47 issue_tracker.assert_has_calls(
48 [mock.call('chromium'),
49 mock.call().getIssue(123),
50 mock.call().update(dummy_issue, 'comment', send_email=True)])
51 self.assertEqual(['label'], dummy_issue.labels)
52
53 @mock.patch('waterfall.post_comment_to_bug_pipeline.IssueTrackerAPI')
54 def testPostCommentToBugWhenDeleted(self, issue_tracker):
55 mocked_instance = mock.Mock()
56 mocked_instance.getIssue.return_value = None
57 issue_tracker.return_value = mocked_instance
58 pipeline = post_comment_to_bug_pipeline.PostCommentToBugPipeline()
59 pipeline.run(123, 'comment', ['label'])
60 issue_tracker.assert_has_calls(
61 [mock.call('chromium'),
62 mock.call().getIssue(123)])
OLDNEW
« 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