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

Side by Side Diff: tests/owners_unittest.py

Issue 6740012: merge in fixes for python 2.5 (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/depot_tools
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 | « owners.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/python 1 #!/usr/bin/python
2 # Copyright (c) 2011 The Chromium Authors. All rights reserved. 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 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 owners.py.""" 6 """Unit tests for owners.py."""
7 7
8 import unittest 8 import unittest
9 9
10 import owners 10 import owners
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
102 102
103 def test_not_covered_by__set_noparent_works(self): 103 def test_not_covered_by__set_noparent_works(self):
104 self.assert_not_covered_by(['content/content.gyp'], [ben], 104 self.assert_not_covered_by(['content/content.gyp'], [ben],
105 ['content/content.gyp']) 105 ['content/content.gyp'])
106 106
107 def test_not_covered_by__valid_inputs(self): 107 def test_not_covered_by__valid_inputs(self):
108 db = self.db() 108 db = self.db()
109 109
110 # Check that we're passed in a sequence that isn't a string. 110 # Check that we're passed in a sequence that isn't a string.
111 self.assertRaises(AssertionError, db.files_not_covered_by, 'foo', []) 111 self.assertRaises(AssertionError, db.files_not_covered_by, 'foo', [])
112 self.assertRaises(AssertionError, db.files_not_covered_by, 112 if hasattr(owners.collections, 'Iterable'):
113 (f for f in ['x', 'y']), []) 113 self.assertRaises(AssertionError, db.files_not_covered_by,
114 (f for f in ['x', 'y']), [])
114 115
115 # Check that the files are under the root. 116 # Check that the files are under the root.
116 db.root = '/checkout' 117 db.root = '/checkout'
117 self.assertRaises(AssertionError, db.files_not_covered_by, ['/OWNERS'], 118 self.assertRaises(AssertionError, db.files_not_covered_by, ['/OWNERS'],
118 []) 119 [])
119 db.root = '/' 120 db.root = '/'
120 121
121 # Check invalid email address. 122 # Check invalid email address.
122 self.assertRaises(AssertionError, db.files_not_covered_by, ['OWNERS'], 123 self.assertRaises(AssertionError, db.files_not_covered_by, ['OWNERS'],
123 ['foo']) 124 ['foo'])
124 125
125 126
126 def assert_reviewers_for(self, files, expected_reviewers): 127 def assert_reviewers_for(self, files, expected_reviewers):
127 db = self.db() 128 db = self.db()
128 self.assertEquals(db.reviewers_for(set(files)), set(expected_reviewers)) 129 self.assertEquals(db.reviewers_for(set(files)), set(expected_reviewers))
129 130
130 def test_reviewers_for__basic_functionality(self): 131 def test_reviewers_for__basic_functionality(self):
131 self.assert_reviewers_for(['chrome/gpu/gpu_channel.h'], 132 self.assert_reviewers_for(['chrome/gpu/gpu_channel.h'],
132 [ken, ben, brett, owners.EVERYONE]) 133 [ken, ben, brett, owners.EVERYONE])
133 134
134 def test_reviewers_for__set_noparent_works(self): 135 def test_reviewers_for__set_noparent_works(self):
135 self.assert_reviewers_for(['content/content.gyp'], [john, darin]) 136 self.assert_reviewers_for(['content/content.gyp'], [john, darin])
136 137
137 def test_reviewers_for__valid_inputs(self): 138 def test_reviewers_for__valid_inputs(self):
138 db = self.db() 139 db = self.db()
139 140
140 # Check that we're passed in a sequence that isn't a string. 141 # Check that we're passed in a sequence that isn't a string.
141 self.assertRaises(AssertionError, db.reviewers_for, 'foo') 142 self.assertRaises(AssertionError, db.reviewers_for, 'foo')
142 self.assertRaises(AssertionError, db.reviewers_for, (f for f in ['x', 'y'])) 143 if hasattr(owners.collections, 'Iterable'):
144 self.assertRaises(AssertionError, db.reviewers_for,
145 (f for f in ['x', 'y']))
143 146
144 # Check that the files are under the root. 147 # Check that the files are under the root.
145 db.root = '/checkout' 148 db.root = '/checkout'
146 self.assertRaises(AssertionError, db.reviewers_for, ['/OWNERS']) 149 self.assertRaises(AssertionError, db.reviewers_for, ['/OWNERS'])
147 150
148 def test_reviewers_for__wildcard_dir(self): 151 def test_reviewers_for__wildcard_dir(self):
149 self.assert_reviewers_for(['DEPS'], [owners.EVERYONE]) 152 self.assert_reviewers_for(['DEPS'], [owners.EVERYONE])
150 153
151 def assert_syntax_error(self, owners_file_contents): 154 def assert_syntax_error(self, owners_file_contents):
152 db = self.db() 155 db = self.db()
(...skipping 10 matching lines...) Expand all
163 166
164 def test_syntax_error__unknown_set(self): 167 def test_syntax_error__unknown_set(self):
165 self.assert_syntax_error('set myfatherisbillgates\n') 168 self.assert_syntax_error('set myfatherisbillgates\n')
166 169
167 def test_syntax_error__bad_email(self): 170 def test_syntax_error__bad_email(self):
168 self.assert_syntax_error('ben\n') 171 self.assert_syntax_error('ben\n')
169 172
170 173
171 if __name__ == '__main__': 174 if __name__ == '__main__':
172 unittest.main() 175 unittest.main()
OLDNEW
« no previous file with comments | « owners.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698