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

Side by Side Diff: tests/committer_revert_test.py

Issue 23483019: Changes to support One-Click Revert in Commit Queue (Closed) Base URL: https://src.chromium.org/chrome/trunk/tools/commit-queue/
Patch Set: Created 7 years, 3 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 | « pending_manager.py ('k') | tests/mocks.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Property Changes:
Added: svn:executable
+ *
OLDNEW
(Empty)
1 #!/usr/bin/env python
2 # Copyright (c) 2013 The Chromium Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file.
5
6 """Unit tests for verification/committer_revert.py."""
7
8 import logging
9 import os
10 import sys
11 import unittest
12
13 ROOT_DIR = os.path.dirname(os.path.abspath(__file__))
14 sys.path.insert(0, os.path.join(ROOT_DIR, '..'))
15
16 from verification import base
17 from verification import committer_revert
18
19 # From tests/
20 import mocks
21
22
23 NO_COMMITTER_ERROR_MSG = committer_revert.CommitterRevertStatus.NO_COMMITTER
24
25
26 class CommitterRevertTest(mocks.TestCase):
27
28 def testRevertBitNotSet(self):
29 self.pending.reverted_by = self.pending.owner
30 try:
31 self._check(None)
32 raise Exception('Expected AssertionError in self._check(None)')
33 except AssertionError:
34 pass # Expected.
35
36 def testCommitterRevert(self):
37 self.pending.revert = True
38 self.pending.reverted_by = self.pending.owner
39 self._check(None)
40
41 def testWrongDomainRevert(self):
42 self.pending.revert = True
43 self.pending.reverted_by = 'georges@example2.com'
44 self._check(NO_COMMITTER_ERROR_MSG)
45
46 def testTBR(self):
47 self.pending.revert = True
48 self.pending.description = 'Webkit roll\nTBR='
49 # TBR does not matter here, revert must always be triggered by a committer.
50 self._check(NO_COMMITTER_ERROR_MSG)
51
52 def testEmptyRevertedBy(self):
53 self.pending.revert = True
54 self.pending.reverted_by = ''
55 self._check(NO_COMMITTER_ERROR_MSG)
56
57 def _check(self, error_message):
58 ver = committer_revert.CommitterRevertVerifier(
59 [r'^[\-\w]+\@example\.com$'])
60 ver.verify(self.pending)
61 ver.update_status([self.pending])
62 name = committer_revert.CommitterRevertVerifier.name
63 self.assertEqual(
64 self.pending.verifications.keys(), [name])
65 self.assertEqual(
66 self.pending.verifications[name].error_message, error_message)
67 if error_message:
68 self.assertEqual(
69 self.pending.verifications[name].get_state(), base.FAILED)
70 else:
71 self.assertEqual(
72 self.pending.verifications[name].get_state(), base.SUCCEEDED)
73
74
75 if __name__ == '__main__':
76 logging.basicConfig(
77 level=[logging.WARNING, logging.INFO, logging.DEBUG][
78 min(sys.argv.count('-v'), 2)],
79 format='%(levelname)5s %(module)15s(%(lineno)3d): %(message)s')
80 unittest.main()
OLDNEW
« no previous file with comments | « pending_manager.py ('k') | tests/mocks.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698