Chromium Code Reviews

Unified Diff: tests/project_base_test.py

Issue 6813044: Add relative path support. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/commit-queue
Patch Set: Created 9 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
« no previous file with comments | « tests/pending_manager_test.py ('k') | verification/project_base.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/project_base_test.py
diff --git a/tests/project_base_test.py b/tests/project_base_test.py
new file mode 100755
index 0000000000000000000000000000000000000000..3214453d7e73acfa4b647af68236522c09ecb2f0
--- /dev/null
+++ b/tests/project_base_test.py
@@ -0,0 +1,90 @@
+#!/usr/bin/env python
+# Copyright (c) 2011 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/project_base.py."""
+
+import logging
+import os
+import re
+import sys
+import unittest
+
+ROOT_DIR = os.path.dirname(os.path.abspath(__file__))
+sys.path.insert(0, os.path.join(ROOT_DIR, '..'))
+
+import find_depot_tools # pylint: disable=W0611
+import breakpad
+
+from verification import project_base
+
+
+class FakePendingCommit(project_base.base.Verified):
+ name = 'FakePendingCommit'
+ owner = 'contributor@example.com'
+ reviewers = []
+ messages = []
+ relpath = ''
+ base_url = 'a'
+
+ def pending_name(self):
+ raise Exception('Fail')
+
+ def patch_url(self):
+ raise Exception('Fail')
+
+
+class ProjectBaseTest(unittest.TestCase):
+ def test_skip(self):
+ pending = FakePendingCommit()
+ self._check(pending, project_base.base.IGNORED, '', False)
+
+ def test_base(self):
+ pending = FakePendingCommit()
+ pending.base_url = 'http://example.com/'
+ self._check(pending, project_base.base.SUCCEEDED, '', False)
+
+ def test_relpath(self):
+ pending = FakePendingCommit()
+ pending.base_url = 'http://example.com/foo/bar'
+ self._check(pending, project_base.base.SUCCEEDED, 'foo/bar', False)
+
+ def test_base_dupe(self):
+ pending = FakePendingCommit()
+ pending.base_url = 'http://example2.com/foo'
+ self._check(pending, project_base.base.SUCCEEDED, 'foo', True)
+
+ def _check(self, pending, state, relpath, expected_stack):
+ stack = []
+ breakpad.SendStack = lambda *args: stack.append(args)
+ base = re.escape('http://example.com/')
+ base2 = re.escape('http://example2.com/')
+ ver = project_base.ProjectBaseUrlVerifier(
+ [
+ r'^%s$' % base,
+ r'^%s(.+)$' % base,
+ r'^%s(.+)$' % base2,
+ r'^%s(.+)$' % base2,
+ ])
+ ver.verify(pending, None)
+ ver.update_status(None)
+ name = project_base.ProjectBaseUrlVerifier.name
+ self.assertEquals([name], pending.verifications.keys())
+ self.assertEquals(None, pending.verifications[name].error_message)
+ self.assertEquals(pending.verifications[name].get_state(), state)
+ self.assertEquals(relpath, pending.relpath)
+ if expected_stack:
+ self.assertEquals(1, len(stack))
+ self.assertEquals(2, len(stack[0]))
+ self.assertEquals(
+ ('pending.base_url triggered multiple matches',), stack[0][0].args)
+ self.assertEquals('', stack[0][1])
+ else:
+ self.assertEquals([], stack)
+
+
+
+if __name__ == '__main__':
+ logging.basicConfig(level=logging.ERROR)
+ unittest.main()
« no previous file with comments | « tests/pending_manager_test.py ('k') | verification/project_base.py » ('j') | no next file with comments »

Powered by Google App Engine