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

Side by Side Diff: prebuilt_unittest.py

Issue 3930001: Update prebuilt.py to filter Packages database. (Closed) Base URL: ssh://git@gitrw.chromium.org:9222/crosutils.git
Patch Set: Typo fix Created 10 years, 2 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 | « prebuilt.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) 2010 The Chromium OS Authors. All rights reserved. 2 # Copyright (c) 2010 The Chromium OS 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 import mox 6 import mox
7 import os 7 import os
8 import prebuilt 8 import prebuilt
9 import shutil 9 import shutil
10 import tempfile 10 import tempfile
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after
184 'overlay-variant-arm-tegra2-vogue', 'make.conf'),} 184 'overlay-variant-arm-tegra2-vogue', 'make.conf'),}
185 for target in targets: 185 for target in targets:
186 self.assertEqual(prebuilt.DetermineMakeConfFile(target), targets[target]) 186 self.assertEqual(prebuilt.DetermineMakeConfFile(target), targets[target])
187 187
188 def testDetermineMakeConfGarbage(self): 188 def testDetermineMakeConfGarbage(self):
189 """Ensure an exception is raised on bad input.""" 189 """Ensure an exception is raised on bad input."""
190 self.assertRaises(prebuilt.UnknownBoardFormat, prebuilt.DetermineMakeConfFil e, 190 self.assertRaises(prebuilt.UnknownBoardFormat, prebuilt.DetermineMakeConfFil e,
191 'asdfasdf') 191 'asdfasdf')
192 192
193 193
194 class TestPackagesFileFiltering(unittest.TestCase):
195
196 def setUp(self):
197 self.mox = mox.Mox()
198
199 def tearDown(self):
200 self.mox.UnsetStubs()
201 self.mox.VerifyAll()
202
203 def testFilterAllPackages(self):
204 self.mox.StubOutWithMock(prebuilt, 'ShouldFilterPackage')
205 prebuilt.ShouldFilterPackage("public1").AndReturn(False)
206 prebuilt.ShouldFilterPackage("private").AndReturn(True)
207 prebuilt.ShouldFilterPackage("public2").AndReturn(False)
208 full_packages_file = [
209 "foo: bar\n", "\n",
210 "CPV: public1\n", "foo: bar1\n", "\n",
211 "CPV: private\n", "foo: bar2\n", "\n",
212 "CPV: public2\n", "foo: bar3\n", "\n",
213 ]
214 private_packages_file = [
215 "foo: bar\n", "\n",
216 "CPV: public1\n", "foo: bar1\n", "\n",
217 "CPV: public2\n", "foo: bar3\n", "\n",
218 ]
219 self.mox.ReplayAll()
220 temp_packages_file = tempfile.NamedTemporaryFile()
221 temp_packages_file.write("".join(full_packages_file))
222 temp_packages_file.flush()
223 new_packages_file = prebuilt.FilterPackagesFile(temp_packages_file.name)
224 new_contents = open(new_packages_file.name).read()
225 self.assertEqual("".join(private_packages_file), new_contents)
226 self.assertEqual("".join(private_packages_file), new_packages_file.read())
227 new_packages_file.close()
228
229
194 if __name__ == '__main__': 230 if __name__ == '__main__':
195 unittest.main() 231 unittest.main()
OLDNEW
« no previous file with comments | « prebuilt.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698