1e14391e94c850b8bd03680c23b38978db68687a8John Reck# Copyright (C) 2009 Google Inc. All rights reserved.
2cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve Block#
3cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve Block# Redistribution and use in source and binary forms, with or without
4cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve Block# modification, are permitted provided that the following conditions are
5cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve Block# met:
6cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve Block#
7e14391e94c850b8bd03680c23b38978db68687a8John Reck#    * Redistributions of source code must retain the above copyright
8cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve Block# notice, this list of conditions and the following disclaimer.
9e14391e94c850b8bd03680c23b38978db68687a8John Reck#    * Redistributions in binary form must reproduce the above
10cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve Block# copyright notice, this list of conditions and the following disclaimer
11cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve Block# in the documentation and/or other materials provided with the
12cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve Block# distribution.
13e14391e94c850b8bd03680c23b38978db68687a8John Reck#    * Neither the name of Google Inc. nor the names of its
14cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve Block# contributors may be used to endorse or promote products derived from
15cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve Block# this software without specific prior written permission.
16cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve Block#
17cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve Block# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
18cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve Block# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
19cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve Block# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
20cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve Block# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
21cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve Block# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
22cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve Block# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
23cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve Block# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve Block# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve Block# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve Block# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
27cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve Block# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve Block
29dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Blockimport unittest
30cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve Block
31e14391e94c850b8bd03680c23b38978db68687a8John Reckfrom webkitpy.common.system.outputcapture import OutputCapture
32e14391e94c850b8bd03680c23b38978db68687a8John Reckfrom webkitpy.tool.mocktool import MockOptions, MockTool
33e14391e94c850b8bd03680c23b38978db68687a8John Reckfrom webkitpy.tool.steps.suggestreviewers import SuggestReviewers
34cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve Block
35cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve Block
36e14391e94c850b8bd03680c23b38978db68687a8John Reckclass SuggestReviewersTest(unittest.TestCase):
37e14391e94c850b8bd03680c23b38978db68687a8John Reck    def test_disabled(self):
38e14391e94c850b8bd03680c23b38978db68687a8John Reck        step = SuggestReviewers(MockTool(), MockOptions(suggest_reviewers=False))
39e14391e94c850b8bd03680c23b38978db68687a8John Reck        OutputCapture().assert_outputs(self, step.run, [{}])
40e14391e94c850b8bd03680c23b38978db68687a8John Reck
41e14391e94c850b8bd03680c23b38978db68687a8John Reck    def test_basic(self):
42e14391e94c850b8bd03680c23b38978db68687a8John Reck        capture = OutputCapture()
43e14391e94c850b8bd03680c23b38978db68687a8John Reck        step = SuggestReviewers(MockTool(), MockOptions(suggest_reviewers=True, git_commit=None))
442fc2651226baac27029e38c9d6ef883fa32084dbSteve Block        expected_stdout = "The following reviewers have recently modified files in your patch:\nFoo Bar\n"
452fc2651226baac27029e38c9d6ef883fa32084dbSteve Block        expected_stderr = "Would you like to CC them?\n"
462fc2651226baac27029e38c9d6ef883fa32084dbSteve Block        capture.assert_outputs(self, step.run, [{"bug_id": "123"}], expected_stdout=expected_stdout, expected_stderr=expected_stderr)
47