| OLD | NEW |
| 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_chrome_as_stable.py.""" | 7 """Unit tests for cros_mark_chrome_as_stable.py.""" |
| 8 | 8 |
| 9 import cros_mark_chrome_as_stable | 9 import cros_mark_chrome_as_stable |
| 10 import mox | 10 import mox |
| (...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 193 ['svn', 'ls', 'http://src.chromium.org/svn/releases'], | 193 ['svn', 'ls', 'http://src.chromium.org/svn/releases'], |
| 194 redirect_stdout=True).AndReturn('some_data') | 194 redirect_stdout=True).AndReturn('some_data') |
| 195 cros_mark_chrome_as_stable.RunCommand( | 195 cros_mark_chrome_as_stable.RunCommand( |
| 196 ['sort', '--version-sort'], input='some_data', | 196 ['sort', '--version-sort'], input='some_data', |
| 197 redirect_stdout=True).AndReturn(test_data) | 197 redirect_stdout=True).AndReturn(test_data) |
| 198 self.mox.ReplayAll() | 198 self.mox.ReplayAll() |
| 199 release = cros_mark_chrome_as_stable._GetLatestRelease(self.sticky_branch) | 199 release = cros_mark_chrome_as_stable._GetLatestRelease(self.sticky_branch) |
| 200 self.mox.VerifyAll() | 200 self.mox.VerifyAll() |
| 201 self.assertEqual('8.0.224.2', release) | 201 self.assertEqual('8.0.224.2', release) |
| 202 | 202 |
| 203 def testStickyVersion(self): | 203 def testStickyEBuild(self): |
| 204 """Tests if we can find the sticky version from our mock directories.""" | 204 """Tests if we can find the sticky ebuild from our mock directories.""" |
| 205 stable_ebuilds = self._GetStableEBuilds() | 205 stable_ebuilds = self._GetStableEBuilds() |
| 206 sticky_version = cros_mark_chrome_as_stable._GetStickyVersion( | 206 sticky_ebuild = cros_mark_chrome_as_stable._GetStickyEBuild( |
| 207 stable_ebuilds) | 207 stable_ebuilds) |
| 208 self.assertEqual(sticky_version, self.sticky_version) | 208 self.assertEqual(sticky_ebuild.chrome_version, self.sticky_version) |
| 209 | 209 |
| 210 def testChromeEBuildInit(self): | 210 def testChromeEBuildInit(self): |
| 211 """Tests if the chrome_version is set correctly in a ChromeEBuild.""" | 211 """Tests if the chrome_version is set correctly in a ChromeEBuild.""" |
| 212 ebuild = cros_mark_chrome_as_stable.ChromeEBuild(self.sticky) | 212 ebuild = cros_mark_chrome_as_stable.ChromeEBuild(self.sticky) |
| 213 self.assertEqual(ebuild.chrome_version, self.sticky_version) | 213 self.assertEqual(ebuild.chrome_version, self.sticky_version) |
| 214 | 214 |
| 215 def _CommonMarkAsStableTest(self, chrome_rev, new_version, old_ebuild_path, | 215 def _CommonMarkAsStableTest(self, chrome_rev, new_version, old_ebuild_path, |
| 216 new_ebuild_path, commit_string_indicator): | 216 new_ebuild_path, commit_string_indicator): |
| 217 """Common function used for test functions for MarkChromeEBuildAsStable. | 217 """Common function used for test functions for MarkChromeEBuildAsStable. |
| 218 | 218 |
| 219 This function stubs out others calls, and runs MarkChromeEBuildAsStable | 219 This function stubs out others calls, and runs MarkChromeEBuildAsStable |
| 220 with the specified args. | 220 with the specified args. |
| 221 | 221 |
| 222 Args: | 222 Args: |
| 223 chrome_rev: standard chrome_rev argument | 223 chrome_rev: standard chrome_rev argument |
| 224 new_version: version we are revving up to | 224 new_version: version we are revving up to |
| 225 old_ebuild_path: path to the stable ebuild | 225 old_ebuild_path: path to the stable ebuild |
| 226 new_ebuild_path: path to the to be created path | 226 new_ebuild_path: path to the to be created path |
| 227 commit_string_indicator: a string that the commit message must contain | 227 commit_string_indicator: a string that the commit message must contain |
| 228 """ | 228 """ |
| 229 self.mox.StubOutWithMock(cros_mark_chrome_as_stable, 'RunCommand') | 229 self.mox.StubOutWithMock(cros_mark_chrome_as_stable, 'RunCommand') |
| 230 self.mox.StubOutWithMock(cros_mark_as_stable.EBuildStableMarker, | 230 self.mox.StubOutWithMock(cros_mark_as_stable.EBuildStableMarker, |
| 231 'CommitChange') | 231 'CommitChange') |
| 232 stable_candidate = cros_mark_chrome_as_stable.ChromeEBuild(old_ebuild_path) | 232 stable_candidate = cros_mark_chrome_as_stable.ChromeEBuild(old_ebuild_path) |
| 233 unstable_ebuild = cros_mark_chrome_as_stable.ChromeEBuild(self.unstable) | 233 unstable_ebuild = cros_mark_chrome_as_stable.ChromeEBuild(self.unstable) |
| 234 sticky_ebuild = cros_mark_chrome_as_stable.ChromeEBuild(self.sticky) |
| 234 chrome_version = new_version | 235 chrome_version = new_version |
| 235 commit = None | 236 commit = None |
| 236 overlay_dir = self.mock_chrome_dir | 237 overlay_dir = self.mock_chrome_dir |
| 237 | 238 |
| 238 cros_mark_chrome_as_stable.RunCommand(['git', 'add', new_ebuild_path]) | 239 cros_mark_chrome_as_stable.RunCommand(['git', 'add', new_ebuild_path]) |
| 239 cros_mark_chrome_as_stable.RunCommand(['git', 'rm', old_ebuild_path]) | 240 cros_mark_chrome_as_stable.RunCommand(['git', 'rm', old_ebuild_path]) |
| 240 cros_mark_as_stable.EBuildStableMarker.CommitChange( | 241 cros_mark_as_stable.EBuildStableMarker.CommitChange( |
| 241 mox.StrContains(commit_string_indicator)) | 242 mox.StrContains(commit_string_indicator)) |
| 242 | 243 |
| 243 self.mox.ReplayAll() | 244 self.mox.ReplayAll() |
| 244 cros_mark_chrome_as_stable.MarkChromeEBuildAsStable( | 245 cros_mark_chrome_as_stable.MarkChromeEBuildAsStable( |
| 245 stable_candidate, unstable_ebuild, chrome_rev, chrome_version, commit, | 246 stable_candidate, unstable_ebuild, chrome_rev, chrome_version, commit, |
| 246 overlay_dir) | 247 overlay_dir, sticky_ebuild) |
| 247 self.mox.VerifyAll() | 248 self.mox.VerifyAll() |
| 248 | 249 |
| 249 def testStickyMarkAsStable(self): | 250 def testStickyMarkAsStable(self): |
| 250 """Tests to see if we can mark chrome as stable for a new sticky release.""" | 251 """Tests to see if we can mark chrome as stable for a new sticky release.""" |
| 251 self._CommonMarkAsStableTest(cros_mark_chrome_as_stable.STICKY, | 252 self._CommonMarkAsStableTest(cros_mark_chrome_as_stable.STICKY, |
| 252 self.sticky_new_rc_version, self.sticky_rc, | 253 self.sticky_new_rc_version, self.sticky_rc, |
| 253 self.sticky_new_rc, 'sticky_release') | 254 self.sticky_new_rc, 'stable_release') |
| 254 | 255 |
| 255 def testLatestMarkAsStable(self): | 256 def testLatestMarkAsStable(self): |
| 256 """Tests to see if we can mark chrome for a latest release.""" | 257 """Tests to see if we can mark chrome for a latest release.""" |
| 257 self._CommonMarkAsStableTest(cros_mark_chrome_as_stable.LATEST_RELEASE, | 258 self._CommonMarkAsStableTest(cros_mark_chrome_as_stable.LATEST_RELEASE, |
| 258 self.latest_new_version, self.latest_stable, | 259 self.latest_new_version, self.latest_stable, |
| 259 self.latest_new, 'latest_release') | 260 self.latest_new, 'latest_release') |
| 260 | 261 |
| 261 def testTotMarkAsStable(self): | 262 def testTotMarkAsStable(self): |
| 262 """Tests to see if we can mark chrome for tot.""" | 263 """Tests to see if we can mark chrome for tot.""" |
| 263 self._CommonMarkAsStableTest(cros_mark_chrome_as_stable.TIP_OF_TRUNK, | 264 self._CommonMarkAsStableTest(cros_mark_chrome_as_stable.TIP_OF_TRUNK, |
| 264 self.tot_new_version, self.tot_stable, | 265 self.tot_new_version, self.tot_stable, |
| 265 self.tot_new, 'tot') | 266 self.tot_new, 'tot') |
| 266 | 267 |
| 267 | 268 |
| 268 if __name__ == '__main__': | 269 if __name__ == '__main__': |
| 269 unittest.main() | 270 unittest.main() |
| OLD | NEW |