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

Side by Side Diff: tests/presubmit_unittest.py

Issue 1960763002: Remove unused PresubmitAddReviewers (Closed) Base URL: https://chromium.googlesource.com/chromium/tools/depot_tools.git@master
Patch Set: . Created 4 years, 7 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 unified diff | Download patch
« no previous file with comments | « presubmit_support.py ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #!/usr/bin/env python 1 #!/usr/bin/env python
2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. 2 # Copyright (c) 2012 The Chromium Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be 3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file. 4 # found in the LICENSE file.
5 5
6 """Unit tests for presubmit_support.py and presubmit_canned_checks.py.""" 6 """Unit tests for presubmit_support.py and presubmit_canned_checks.py."""
7 7
8 # pylint: disable=E1101,E1103 8 # pylint: disable=E1101,E1103
9 9
10 import StringIO 10 import StringIO
(...skipping 1576 matching lines...) Expand 10 before | Expand all | Expand 10 after
1587 None, False) 1587 None, False)
1588 input_api.ReadFile(fileobj, 'x') 1588 input_api.ReadFile(fileobj, 'x')
1589 1589
1590 1590
1591 class OutputApiUnittest(PresubmitTestsBase): 1591 class OutputApiUnittest(PresubmitTestsBase):
1592 """Tests presubmit.OutputApi.""" 1592 """Tests presubmit.OutputApi."""
1593 1593
1594 def testMembersChanged(self): 1594 def testMembersChanged(self):
1595 self.mox.ReplayAll() 1595 self.mox.ReplayAll()
1596 members = [ 1596 members = [
1597 'MailTextResult', 'PresubmitAddReviewers', 'PresubmitError', 1597 'MailTextResult', 'PresubmitError', 'PresubmitNotifyResult',
1598 'PresubmitNotifyResult', 'PresubmitPromptWarning', 1598 'PresubmitPromptWarning', 'PresubmitPromptOrNotify', 'PresubmitResult',
1599 'PresubmitPromptOrNotify', 'PresubmitResult', 'is_committing', 1599 'is_committing',
1600 ] 1600 ]
1601 # If this test fails, you should add the relevant test. 1601 # If this test fails, you should add the relevant test.
1602 self.compareMembers(presubmit.OutputApi(False), members) 1602 self.compareMembers(presubmit.OutputApi(False), members)
1603 1603
1604 def testOutputApiBasics(self): 1604 def testOutputApiBasics(self):
1605 self.mox.ReplayAll() 1605 self.mox.ReplayAll()
1606 self.failUnless(presubmit.OutputApi.PresubmitError('').fatal) 1606 self.failUnless(presubmit.OutputApi.PresubmitError('').fatal)
1607 self.failIf(presubmit.OutputApi.PresubmitError('').should_prompt) 1607 self.failIf(presubmit.OutputApi.PresubmitError('').should_prompt)
1608 1608
1609 self.failIf(presubmit.OutputApi.PresubmitPromptWarning('').fatal) 1609 self.failIf(presubmit.OutputApi.PresubmitPromptWarning('').fatal)
1610 self.failUnless( 1610 self.failUnless(
1611 presubmit.OutputApi.PresubmitPromptWarning('').should_prompt) 1611 presubmit.OutputApi.PresubmitPromptWarning('').should_prompt)
1612 1612
1613 self.failIf(presubmit.OutputApi.PresubmitNotifyResult('').fatal) 1613 self.failIf(presubmit.OutputApi.PresubmitNotifyResult('').fatal)
1614 self.failIf(presubmit.OutputApi.PresubmitNotifyResult('').should_prompt) 1614 self.failIf(presubmit.OutputApi.PresubmitNotifyResult('').should_prompt)
1615 1615
1616 self.failIf(presubmit.OutputApi.PresubmitAddReviewers(
1617 ['foo']).fatal)
1618 self.failIf(presubmit.OutputApi.PresubmitAddReviewers(
1619 ['foo']).should_prompt)
1620
1621 # TODO(joi) Test MailTextResult once implemented. 1616 # TODO(joi) Test MailTextResult once implemented.
1622 1617
1623 def testOutputApiHandling(self): 1618 def testOutputApiHandling(self):
1624 self.mox.ReplayAll() 1619 self.mox.ReplayAll()
1625 1620
1626 output = presubmit.PresubmitOutput() 1621 output = presubmit.PresubmitOutput()
1627 presubmit.OutputApi.PresubmitAddReviewers(
1628 ['ben@example.com']).handle(output)
1629 self.failUnless(output.should_continue())
1630 self.failUnlessEqual(output.reviewers, ['ben@example.com'])
1631
1632 output = presubmit.PresubmitOutput()
1633 presubmit.OutputApi.PresubmitError('!!!').handle(output) 1622 presubmit.OutputApi.PresubmitError('!!!').handle(output)
1634 self.failIf(output.should_continue()) 1623 self.failIf(output.should_continue())
1635 self.failUnless(output.getvalue().count('!!!')) 1624 self.failUnless(output.getvalue().count('!!!'))
1636 1625
1637 output = presubmit.PresubmitOutput() 1626 output = presubmit.PresubmitOutput()
1638 presubmit.OutputApi.PresubmitNotifyResult('?see?').handle(output) 1627 presubmit.OutputApi.PresubmitNotifyResult('?see?').handle(output)
1639 self.failUnless(output.should_continue()) 1628 self.failUnless(output.should_continue())
1640 self.failUnless(output.getvalue().count('?see?')) 1629 self.failUnless(output.getvalue().count('?see?'))
1641 1630
1642 output = presubmit.PresubmitOutput(input_stream=StringIO.StringIO('y')) 1631 output = presubmit.PresubmitOutput(input_stream=StringIO.StringIO('y'))
(...skipping 1289 matching lines...) Expand 10 before | Expand all | Expand 10 after
2932 owners_check=False) 2921 owners_check=False)
2933 self.assertEqual(2, len(results)) 2922 self.assertEqual(2, len(results))
2934 self.assertEqual( 2923 self.assertEqual(
2935 'Found line ending with white spaces in:', results[0]._message) 2924 'Found line ending with white spaces in:', results[0]._message)
2936 self.checkstdout('') 2925 self.checkstdout('')
2937 2926
2938 2927
2939 if __name__ == '__main__': 2928 if __name__ == '__main__':
2940 import unittest 2929 import unittest
2941 unittest.main() 2930 unittest.main()
OLDNEW
« no previous file with comments | « presubmit_support.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698