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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « pending_manager.py ('k') | tests/mocks.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/committer_revert_test.py
===================================================================
--- tests/committer_revert_test.py (revision 0)
+++ tests/committer_revert_test.py (revision 0)
@@ -0,0 +1,80 @@
+#!/usr/bin/env python
+# Copyright (c) 2013 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.
+
+"""Unit tests for verification/committer_revert.py."""
+
+import logging
+import os
+import sys
+import unittest
+
+ROOT_DIR = os.path.dirname(os.path.abspath(__file__))
+sys.path.insert(0, os.path.join(ROOT_DIR, '..'))
+
+from verification import base
+from verification import committer_revert
+
+# From tests/
+import mocks
+
+
+NO_COMMITTER_ERROR_MSG = committer_revert.CommitterRevertStatus.NO_COMMITTER
+
+
+class CommitterRevertTest(mocks.TestCase):
+
+ def testRevertBitNotSet(self):
+ self.pending.reverted_by = self.pending.owner
+ try:
+ self._check(None)
+ raise Exception('Expected AssertionError in self._check(None)')
+ except AssertionError:
+ pass # Expected.
+
+ def testCommitterRevert(self):
+ self.pending.revert = True
+ self.pending.reverted_by = self.pending.owner
+ self._check(None)
+
+ def testWrongDomainRevert(self):
+ self.pending.revert = True
+ self.pending.reverted_by = 'georges@example2.com'
+ self._check(NO_COMMITTER_ERROR_MSG)
+
+ def testTBR(self):
+ self.pending.revert = True
+ self.pending.description = 'Webkit roll\nTBR='
+ # TBR does not matter here, revert must always be triggered by a committer.
+ self._check(NO_COMMITTER_ERROR_MSG)
+
+ def testEmptyRevertedBy(self):
+ self.pending.revert = True
+ self.pending.reverted_by = ''
+ self._check(NO_COMMITTER_ERROR_MSG)
+
+ def _check(self, error_message):
+ ver = committer_revert.CommitterRevertVerifier(
+ [r'^[\-\w]+\@example\.com$'])
+ ver.verify(self.pending)
+ ver.update_status([self.pending])
+ name = committer_revert.CommitterRevertVerifier.name
+ self.assertEqual(
+ self.pending.verifications.keys(), [name])
+ self.assertEqual(
+ self.pending.verifications[name].error_message, error_message)
+ if error_message:
+ self.assertEqual(
+ self.pending.verifications[name].get_state(), base.FAILED)
+ else:
+ self.assertEqual(
+ self.pending.verifications[name].get_state(), base.SUCCEEDED)
+
+
+if __name__ == '__main__':
+ logging.basicConfig(
+ level=[logging.WARNING, logging.INFO, logging.DEBUG][
+ min(sys.argv.count('-v'), 2)],
+ format='%(levelname)5s %(module)15s(%(lineno)3d): %(message)s')
+ unittest.main()
Property changes on: tests/committer_revert_test.py
___________________________________________________________________
Added: svn:executable
+ *
« 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