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

Side by Side Diff: cros_mark_as_stable_unittest.py

Issue 4449001: Add 0.0.1 logic to new cros_mark. (Closed) Base URL: http://git.chromium.org/git/crosutils.git@master
Patch Set: Created 10 years, 1 month 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 | « cros_mark_as_stable.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 2
3 # Copyright (c) 2010 The Chromium OS Authors. All rights reserved. 3 # Copyright (c) 2010 The Chromium OS Authors. All rights reserved.
4 # Use of this source code is governed by a BSD-style license that can be 4 # Use of this source code is governed by a BSD-style license that can be
5 # found in the LICENSE file. 5 # found in the LICENSE file.
6 6
7 """Unit tests for cros_mark_as_stable.py.""" 7 """Unit tests for cros_mark_as_stable.py."""
8 8
9 9
10 import mox 10 import mox
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
118 # Test with ebuild with revision number. 118 # Test with ebuild with revision number.
119 no_rev, no_version, revision = cros_mark_as_stable._EBuild._ParseEBuildPath( 119 no_rev, no_version, revision = cros_mark_as_stable._EBuild._ParseEBuildPath(
120 '/path/test_package-0.0.1-r1.ebuild') 120 '/path/test_package-0.0.1-r1.ebuild')
121 self.assertEquals(no_rev, '/path/test_package-0.0.1') 121 self.assertEquals(no_rev, '/path/test_package-0.0.1')
122 self.assertEquals(no_version, '/path/test_package') 122 self.assertEquals(no_version, '/path/test_package')
123 self.assertEquals(revision, 1) 123 self.assertEquals(revision, 1)
124 124
125 def testParseEBuildPathNoRevisionNumber(self): 125 def testParseEBuildPathNoRevisionNumber(self):
126 # Test with ebuild without revision number. 126 # Test with ebuild without revision number.
127 no_rev, no_version, revision = cros_mark_as_stable._EBuild._ParseEBuildPath( 127 no_rev, no_version, revision = cros_mark_as_stable._EBuild._ParseEBuildPath(
128 '/path/test_package-0.0.1.ebuild') 128 '/path/test_package-9999.ebuild')
129 self.assertEquals(no_rev, '/path/test_package-0.0.1') 129 self.assertEquals(no_rev, '/path/test_package-0.0.1')
130 self.assertEquals(no_version, '/path/test_package') 130 self.assertEquals(no_version, '/path/test_package')
131 self.assertEquals(revision, 0) 131 self.assertEquals(revision, 0)
132 132
133 133
134 class EBuildStableMarkerTest(mox.MoxTestBase): 134 class EBuildStableMarkerTest(mox.MoxTestBase):
135 135
136 def setUp(self): 136 def setUp(self):
137 mox.MoxTestBase.setUp(self) 137 mox.MoxTestBase.setUp(self)
138 self.mox.StubOutWithMock(cros_mark_as_stable, '_SimpleRunCommand') 138 self.mox.StubOutWithMock(cros_mark_as_stable, '_SimpleRunCommand')
139 self.mox.StubOutWithMock(cros_mark_as_stable, 'RunCommand') 139 self.mox.StubOutWithMock(cros_mark_as_stable, 'RunCommand')
140 self.mox.StubOutWithMock(os, 'unlink') 140 self.mox.StubOutWithMock(os, 'unlink')
141 self.m_ebuild = self.mox.CreateMock(cros_mark_as_stable._EBuild) 141 self.m_ebuild = self.mox.CreateMock(cros_mark_as_stable._EBuild)
142 self.m_ebuild.is_stable = True
142 self.m_ebuild.package = 'test_package' 143 self.m_ebuild.package = 'test_package'
143 self.m_ebuild.current_revision = 1 144 self.m_ebuild.current_revision = 1
144 self.m_ebuild.ebuild_path_no_revision = '/path/test_package-0.0.1' 145 self.m_ebuild.ebuild_path_no_revision = '/path/test_package-0.0.1'
145 self.m_ebuild.ebuild_path_no_version = '/path/test_package' 146 self.m_ebuild.ebuild_path_no_version = '/path/test_package'
146 self.m_ebuild.ebuild_path = '/path/test_package-0.0.1-r1.ebuild' 147 self.m_ebuild.ebuild_path = '/path/test_package-0.0.1-r1.ebuild'
147 self.revved_ebuild_path = '/path/test_package-0.0.1-r2.ebuild' 148 self.revved_ebuild_path = '/path/test_package-0.0.1-r2.ebuild'
148 149
149 def testRevEBuild(self): 150 def testRevEBuild(self):
150 self.mox.StubOutWithMock(cros_mark_as_stable.fileinput, 'input') 151 self.mox.StubOutWithMock(cros_mark_as_stable.fileinput, 'input')
151 self.mox.StubOutWithMock(cros_mark_as_stable.os.path, 'exists') 152 self.mox.StubOutWithMock(cros_mark_as_stable.os.path, 'exists')
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
274 275
275 def setUp(self): 276 def setUp(self):
276 mox.MoxTestBase.setUp(self) 277 mox.MoxTestBase.setUp(self)
277 self.mox.StubOutWithMock(cros_mark_as_stable.os, 'walk') 278 self.mox.StubOutWithMock(cros_mark_as_stable.os, 'walk')
278 self.mox.StubOutWithMock(cros_mark_as_stable, 'RunCommand') 279 self.mox.StubOutWithMock(cros_mark_as_stable, 'RunCommand')
279 self.package = 'chromeos-base/test_package' 280 self.package = 'chromeos-base/test_package'
280 self.root = '/overlay/chromeos-base/test_package' 281 self.root = '/overlay/chromeos-base/test_package'
281 self.package_path = self.root + '/test_package-0.0.1.ebuild' 282 self.package_path = self.root + '/test_package-0.0.1.ebuild'
282 paths = [[self.root, [], []]] 283 paths = [[self.root, [], []]]
283 cros_mark_as_stable.os.walk("/overlay").AndReturn(paths) 284 cros_mark_as_stable.os.walk("/overlay").AndReturn(paths)
284 self.mox.StubOutWithMock(cros_mark_as_stable, '_FindStableEBuilds') 285 self.mox.StubOutWithMock(cros_mark_as_stable, '_FindUprevCandidates')
285 286
286 287
287 def testWantedPackage(self): 288 def testWantedPackage(self):
288 overlays = {"/overlay": []} 289 overlays = {"/overlay": []}
289 package = _Package(self.package) 290 package = _Package(self.package)
290 cros_mark_as_stable._FindStableEBuilds([]).AndReturn(package) 291 cros_mark_as_stable._FindUprevCandidates([]).AndReturn(package)
291 self.mox.ReplayAll() 292 self.mox.ReplayAll()
292 cros_mark_as_stable._BuildEBuildDictionary(overlays, False, [self.package]) 293 cros_mark_as_stable._BuildEBuildDictionary(overlays, False, [self.package])
293 self.mox.VerifyAll() 294 self.mox.VerifyAll()
294 self.assertEquals(len(overlays), 1) 295 self.assertEquals(len(overlays), 1)
295 self.assertEquals(overlays["/overlay"], [package]) 296 self.assertEquals(overlays["/overlay"], [package])
296 297
297 def testUnwantedPackage(self): 298 def testUnwantedPackage(self):
298 overlays = {"/overlay": []} 299 overlays = {"/overlay": []}
299 package = _Package(self.package) 300 package = _Package(self.package)
300 cros_mark_as_stable._FindStableEBuilds([]).AndReturn(package) 301 cros_mark_as_stable._FindUprevCandidates([]).AndReturn(package)
301 self.mox.ReplayAll() 302 self.mox.ReplayAll()
302 cros_mark_as_stable._BuildEBuildDictionary(overlays, False, []) 303 cros_mark_as_stable._BuildEBuildDictionary(overlays, False, [])
303 self.assertEquals(len(overlays), 1) 304 self.assertEquals(len(overlays), 1)
304 self.assertEquals(overlays["/overlay"], []) 305 self.assertEquals(overlays["/overlay"], [])
305 self.mox.VerifyAll() 306 self.mox.VerifyAll()
306 307
307 308
308 if __name__ == '__main__': 309 if __name__ == '__main__':
309 unittest.main() 310 unittest.main()
OLDNEW
« no previous file with comments | « cros_mark_as_stable.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698