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

Side by Side 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. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « tests/pending_manager_test.py ('k') | verification/project_base.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 #!/usr/bin/env python
2 # Copyright (c) 2011 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/project_base.py."""
7
8 import logging
9 import os
10 import re
11 import sys
12 import unittest
13
14 ROOT_DIR = os.path.dirname(os.path.abspath(__file__))
15 sys.path.insert(0, os.path.join(ROOT_DIR, '..'))
16
17 import find_depot_tools # pylint: disable=W0611
18 import breakpad
19
20 from verification import project_base
21
22
23 class FakePendingCommit(project_base.base.Verified):
24 name = 'FakePendingCommit'
25 owner = 'contributor@example.com'
26 reviewers = []
27 messages = []
28 relpath = ''
29 base_url = 'a'
30
31 def pending_name(self):
32 raise Exception('Fail')
33
34 def patch_url(self):
35 raise Exception('Fail')
36
37
38 class ProjectBaseTest(unittest.TestCase):
39 def test_skip(self):
40 pending = FakePendingCommit()
41 self._check(pending, project_base.base.IGNORED, '', False)
42
43 def test_base(self):
44 pending = FakePendingCommit()
45 pending.base_url = 'http://example.com/'
46 self._check(pending, project_base.base.SUCCEEDED, '', False)
47
48 def test_relpath(self):
49 pending = FakePendingCommit()
50 pending.base_url = 'http://example.com/foo/bar'
51 self._check(pending, project_base.base.SUCCEEDED, 'foo/bar', False)
52
53 def test_base_dupe(self):
54 pending = FakePendingCommit()
55 pending.base_url = 'http://example2.com/foo'
56 self._check(pending, project_base.base.SUCCEEDED, 'foo', True)
57
58 def _check(self, pending, state, relpath, expected_stack):
59 stack = []
60 breakpad.SendStack = lambda *args: stack.append(args)
61 base = re.escape('http://example.com/')
62 base2 = re.escape('http://example2.com/')
63 ver = project_base.ProjectBaseUrlVerifier(
64 [
65 r'^%s$' % base,
66 r'^%s(.+)$' % base,
67 r'^%s(.+)$' % base2,
68 r'^%s(.+)$' % base2,
69 ])
70 ver.verify(pending, None)
71 ver.update_status(None)
72 name = project_base.ProjectBaseUrlVerifier.name
73 self.assertEquals([name], pending.verifications.keys())
74 self.assertEquals(None, pending.verifications[name].error_message)
75 self.assertEquals(pending.verifications[name].get_state(), state)
76 self.assertEquals(relpath, pending.relpath)
77 if expected_stack:
78 self.assertEquals(1, len(stack))
79 self.assertEquals(2, len(stack[0]))
80 self.assertEquals(
81 ('pending.base_url triggered multiple matches',), stack[0][0].args)
82 self.assertEquals('', stack[0][1])
83 else:
84 self.assertEquals([], stack)
85
86
87
88 if __name__ == '__main__':
89 logging.basicConfig(level=logging.ERROR)
90 unittest.main()
OLDNEW
« 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
This is Rietveld 408576698