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

Unified Diff: cros_mark_as_stable_unittest.py

Issue 3516025: Update cros_mark_as_stable.py to also update the private overlay (Closed) Base URL: ssh://git@gitrw.chromium.org:9222/crosutils.git
Patch Set: Fix nits 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « cros_mark_as_stable.py ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cros_mark_as_stable_unittest.py
diff --git a/cros_mark_as_stable_unittest.py b/cros_mark_as_stable_unittest.py
index ce5152f5b5fefe8579f9a85b318fa30f46f1e552..5520b1f140fcb7a205568ef7b8cf2368e97cdd65 100755
--- a/cros_mark_as_stable_unittest.py
+++ b/cros_mark_as_stable_unittest.py
@@ -157,6 +157,7 @@ class EBuildStableMarkerTest(mox.MoxTestBase):
def testRevEBuild(self):
self.mox.StubOutWithMock(cros_mark_as_stable.fileinput, 'input')
+ self.mox.StubOutWithMock(cros_mark_as_stable.os.path, 'exists')
self.mox.StubOutWithMock(cros_mark_as_stable.shutil, 'copyfile')
m_file = self.mox.CreateMock(file)
@@ -165,9 +166,39 @@ class EBuildStableMarkerTest(mox.MoxTestBase):
mock_file = ['EAPI=2', 'CROS_WORKON_COMMIT=old_id',
'KEYWORDS=\"~x86 ~arm\"', 'src_unpack(){}']
- cros_mark_as_stable.shutil.copyfile(
- self.m_ebuild.ebuild_path_no_version + '-9999.ebuild',
- self.revved_ebuild_path)
+ ebuild_9999 = self.m_ebuild.ebuild_path_no_version + '-9999.ebuild'
+ cros_mark_as_stable.os.path.exists(ebuild_9999).AndReturn(True)
+ cros_mark_as_stable.shutil.copyfile(ebuild_9999, self.revved_ebuild_path)
+ cros_mark_as_stable.fileinput.input(self.revved_ebuild_path,
+ inplace=1).AndReturn(mock_file)
+ m_file.write('EAPI=2')
+ m_file.write('CROS_WORKON_COMMIT="my_id"\n')
+ m_file.write('KEYWORDS="x86 arm"')
+ m_file.write('src_unpack(){}')
+ cros_mark_as_stable._SimpleRunCommand('git add ' + self.revved_ebuild_path)
+ cros_mark_as_stable._SimpleRunCommand('git rm ' + self.m_ebuild.ebuild_path)
+
+ self.mox.ReplayAll()
+ marker = cros_mark_as_stable.EBuildStableMarker(self.m_ebuild)
+ marker.RevEBuild('my_id', redirect_file=m_file)
+ self.mox.VerifyAll()
+
+ def testRevMissingEBuild(self):
+ self.mox.StubOutWithMock(cros_mark_as_stable.fileinput, 'input')
+ self.mox.StubOutWithMock(cros_mark_as_stable.os.path, 'exists')
+ self.mox.StubOutWithMock(cros_mark_as_stable.shutil, 'copyfile')
+ self.mox.StubOutWithMock(cros_mark_as_stable, 'Die')
+ m_file = self.mox.CreateMock(file)
+
+ # Prepare mock fileinput. This tests to make sure both the commit id
+ # and keywords are changed correctly.
+ mock_file = ['EAPI=2', 'CROS_WORKON_COMMIT=old_id',
+ 'KEYWORDS=\"~x86 ~arm\"', 'src_unpack(){}']
+
+ ebuild_9999 = self.m_ebuild.ebuild_path_no_version + '-9999.ebuild'
+ cros_mark_as_stable.os.path.exists(ebuild_9999).AndReturn(False)
+ cros_mark_as_stable.Die("Missing 9999 ebuild: %s" % ebuild_9999)
+ cros_mark_as_stable.shutil.copyfile(ebuild_9999, self.revved_ebuild_path)
cros_mark_as_stable.fileinput.input(self.revved_ebuild_path,
inplace=1).AndReturn(mock_file)
m_file.write('EAPI=2')
@@ -200,6 +231,51 @@ class EBuildStableMarkerTest(mox.MoxTestBase):
#self.mox.VerifyAll()
pass
+class BuildEBuildDictionaryTest(mox.MoxTestBase):
+
+ def setUp(self):
+ mox.MoxTestBase.setUp(self)
+ self.mox.StubOutWithMock(cros_mark_as_stable, '_SimpleRunCommand')
+ self.ebuild_path = '/path/test_package-0.0.1-r1.ebuild'
+ self.package = "test_package"
+
+ def testValidPackage(self):
+ overlays = {"/path": []}
+ cmd = ('ACCEPT_KEYWORDS="x86 arm amd64" '
+ 'equery-x86-generic which %s 2> /dev/null' % self.package)
+ cros_mark_as_stable._SimpleRunCommand(cmd).AndReturn(self.ebuild_path)
+ self.mox.ReplayAll()
+ cros_mark_as_stable._BuildEBuildDictionary(overlays, [self.package], [])
+ self.assertEquals(len(overlays), 1)
+ self.assertEquals(overlays["/path"][0].package, self.package)
+ self.mox.VerifyAll()
+
+ def testPackageInDifferentOverlay(self):
+ self.mox.StubOutWithMock(cros_mark_as_stable, 'Die')
+ cros_mark_as_stable.Die("No overlay found for %s" % self.ebuild_path)
+ cmd = ('ACCEPT_KEYWORDS="x86 arm amd64" '
+ 'equery-x86-generic which %s 2> /dev/null' % self.package)
+ cros_mark_as_stable._SimpleRunCommand(cmd).AndReturn(self.ebuild_path)
+ overlays = {"/newpath": []}
+ self.mox.ReplayAll()
+ cros_mark_as_stable._BuildEBuildDictionary(overlays, [self.package], [])
+ self.assertEquals(len(overlays), 1)
+ self.assertEquals(overlays["/newpath"], [])
+ self.mox.VerifyAll()
+
+ def testMissingPackage(self):
+ self.mox.StubOutWithMock(cros_mark_as_stable, 'Die')
+ cros_mark_as_stable.Die("No ebuild found for %s" % self.package)
+ cmd = ('ACCEPT_KEYWORDS="x86 arm amd64" '
+ 'equery-x86-generic which %s 2> /dev/null' % self.package)
+ cros_mark_as_stable._SimpleRunCommand(cmd).AndReturn("")
+ self.mox.ReplayAll()
+ overlays = {"/path": []}
+ cros_mark_as_stable._BuildEBuildDictionary(overlays, [self.package], [])
+ self.assertEquals(len(overlays), 1)
+ self.assertEquals(overlays["/path"], [])
+ self.mox.VerifyAll()
+
if __name__ == '__main__':
unittest.main()
« 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