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

Side by Side Diff: cros_mark_as_stable_unittest.py

Issue 5172003: The major change is refactoring to make functions more accessible for other modules. (Closed) Base URL: http://git.chromium.org/git/crosutils.git@master
Patch Set: Re-add option 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
« cros_mark_as_stable.py ('K') | « 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 import fileinput
10 import mox 10 import mox
11 import os 11 import os
12 import sys 12 import sys
13 import unittest 13 import unittest
14 14
15 # Required to include '.' in the python path.
16 sys.path.append(os.path.dirname(__file__))
17 import cros_mark_as_stable 15 import cros_mark_as_stable
18 16
17 class NonClassTests(mox.MoxTestBase):
18 def setUp(self):
19 mox.MoxTestBase.setUp(self)
20 self.mox.StubOutWithMock(cros_mark_as_stable, '_SimpleRunCommand')
21 self._branch = 'test_branch'
22 self._tracking_branch = 'cros/test'
23
24 def testPushChange(self):
25 git_log = 'Marking test_one as stable\nMarking test_two as stable\n'
26 fake_description = 'Marking set of ebuilds as stable\n\n%s' % git_log
27 self.mox.StubOutWithMock(cros_mark_as_stable, '_CheckOnStabilizingBranch')
28 self.mox.StubOutWithMock(cros_mark_as_stable.GitBranch, 'CreateBranch')
29 self.mox.StubOutWithMock(cros_mark_as_stable.GitBranch, 'Exists')
30
31 cros_mark_as_stable._CheckOnStabilizingBranch(self._branch).AndReturn(True)
32 cros_mark_as_stable.GitBranch.CreateBranch()
33 cros_mark_as_stable.GitBranch.Exists().AndReturn(True)
34 cros_mark_as_stable._SimpleRunCommand('git log --format=format:%s%n%n%b ' +
35 self._tracking_branch + '..').AndReturn(git_log)
36 cros_mark_as_stable._SimpleRunCommand('git remote update')
37 cros_mark_as_stable._SimpleRunCommand('git merge --squash %s' %
38 self._branch)
39 cros_mark_as_stable._SimpleRunCommand('git commit -m "%s"' %
40 fake_description)
41 cros_mark_as_stable._SimpleRunCommand('git config push.default tracking')
42 cros_mark_as_stable._SimpleRunCommand('git push')
43 self.mox.ReplayAll()
44 cros_mark_as_stable.PushChange(self._branch, self._tracking_branch)
45 self.mox.VerifyAll()
46
47
19 class GitBranchTest(mox.MoxTestBase): 48 class GitBranchTest(mox.MoxTestBase):
20 49
21 def setUp(self): 50 def setUp(self):
22 mox.MoxTestBase.setUp(self) 51 mox.MoxTestBase.setUp(self)
23 # Always stub RunCommmand out as we use it in every method. 52 # Always stub RunCommmand out as we use it in every method.
24 self.mox.StubOutWithMock(cros_mark_as_stable, '_SimpleRunCommand') 53 self.mox.StubOutWithMock(cros_mark_as_stable, '_SimpleRunCommand')
25 self._branch = 'test_branch' 54 self._branch = 'test_branch'
55 self._tracking_branch = 'cros/test'
26 56
27 def testCreateBranchNoPrevious(self): 57 def testCreateBranchNoPrevious(self):
28 # Test init with no previous branch existing. 58 # Test init with no previous branch existing.
29 branch = cros_mark_as_stable._GitBranch(self._branch) 59 branch = cros_mark_as_stable.GitBranch(self._branch, self._tracking_branch)
30 self.mox.StubOutWithMock(branch, 'Exists') 60 self.mox.StubOutWithMock(branch, 'Exists')
31 self.mox.StubOutWithMock(branch, '_Checkout') 61 self.mox.StubOutWithMock(branch, '_Checkout')
32 branch.Exists().AndReturn(False) 62 branch.Exists().AndReturn(False)
33 branch._Checkout(self._branch) 63 branch._Checkout(self._branch)
34 self.mox.ReplayAll() 64 self.mox.ReplayAll()
35 branch.CreateBranch() 65 branch.CreateBranch()
36 self.mox.VerifyAll() 66 self.mox.VerifyAll()
37 67
38 def testCreateBranchWithPrevious(self): 68 def testCreateBranchWithPrevious(self):
39 # Test init with previous branch existing. 69 # Test init with previous branch existing.
40 branch = cros_mark_as_stable._GitBranch(self._branch) 70 branch = cros_mark_as_stable.GitBranch(self._branch, self._tracking_branch)
41 self.mox.StubOutWithMock(branch, 'Exists') 71 self.mox.StubOutWithMock(branch, 'Exists')
42 self.mox.StubOutWithMock(branch, 'Delete') 72 self.mox.StubOutWithMock(branch, 'Delete')
43 self.mox.StubOutWithMock(branch, '_Checkout') 73 self.mox.StubOutWithMock(branch, '_Checkout')
44 branch.Exists().AndReturn(True) 74 branch.Exists().AndReturn(True)
45 branch.Delete() 75 branch.Delete()
46 branch._Checkout(self._branch) 76 branch._Checkout(self._branch)
47 self.mox.ReplayAll() 77 self.mox.ReplayAll()
48 branch.CreateBranch() 78 branch.CreateBranch()
49 self.mox.VerifyAll() 79 self.mox.VerifyAll()
50 80
51 def testCheckoutCreate(self): 81 def testCheckoutCreate(self):
52 # Test init with no previous branch existing. 82 # Test init with no previous branch existing.
53 cros_mark_as_stable._SimpleRunCommand( 83 cros_mark_as_stable._SimpleRunCommand(
54 'git checkout -b %s cros/master' % self._branch) 84 'git checkout -b %s %s' % (self._branch, self._tracking_branch))
55 self.mox.ReplayAll() 85 self.mox.ReplayAll()
56 branch = cros_mark_as_stable._GitBranch(self._branch) 86 branch = cros_mark_as_stable.GitBranch(self._branch, self._tracking_branch)
57 branch._Checkout(self._branch) 87 branch._Checkout(self._branch)
58 self.mox.VerifyAll() 88 self.mox.VerifyAll()
59 89
60 def testCheckoutNoCreate(self): 90 def testCheckoutNoCreate(self):
61 # Test init with previous branch existing. 91 # Test init with previous branch existing.
62 cros_mark_as_stable._SimpleRunCommand('git checkout cros/master') 92 cros_mark_as_stable._SimpleRunCommand('git checkout %s' % (
93 self._tracking_branch))
63 self.mox.ReplayAll() 94 self.mox.ReplayAll()
64 branch = cros_mark_as_stable._GitBranch(self._branch) 95 branch = cros_mark_as_stable.GitBranch(self._branch, self._tracking_branch)
65 branch._Checkout('cros/master', False) 96 branch._Checkout(self._tracking_branch, False)
66 self.mox.VerifyAll() 97 self.mox.VerifyAll()
67 98
68 def testDelete(self): 99 def testDelete(self):
69 branch = cros_mark_as_stable._GitBranch(self._branch) 100 branch = cros_mark_as_stable.GitBranch(self._branch, self._tracking_branch)
70 self.mox.StubOutWithMock(branch, '_Checkout') 101 self.mox.StubOutWithMock(branch, '_Checkout')
71 branch._Checkout('cros/master', create=False) 102 branch._Checkout(self._tracking_branch, create=False)
72 cros_mark_as_stable._SimpleRunCommand('git branch -D ' + self._branch) 103 cros_mark_as_stable._SimpleRunCommand('git branch -D ' + self._branch)
73 self.mox.ReplayAll() 104 self.mox.ReplayAll()
74 branch.Delete() 105 branch.Delete()
75 self.mox.VerifyAll() 106 self.mox.VerifyAll()
76 107
77 def testExists(self): 108 def testExists(self):
78 branch = cros_mark_as_stable._GitBranch(self._branch) 109 branch = cros_mark_as_stable.GitBranch(self._branch, self._tracking_branch)
79 110
80 # Test if branch exists that is created 111 # Test if branch exists that is created
81 cros_mark_as_stable._SimpleRunCommand('git branch').AndReturn( 112 cros_mark_as_stable._SimpleRunCommand('git branch').AndReturn(
82 '%s %s' % (self._branch, 'cros/master')) 113 '%s %s' % (self._branch, self._tracking_branch))
83 self.mox.ReplayAll() 114 self.mox.ReplayAll()
84 self.assertTrue(branch.Exists()) 115 self.assertTrue(branch.Exists())
85 self.mox.VerifyAll() 116 self.mox.VerifyAll()
86 117
87 118
88 class EBuildTest(mox.MoxTestBase): 119 class EBuildTest(mox.MoxTestBase):
89 120
90 def setUp(self): 121 def setUp(self):
91 mox.MoxTestBase.setUp(self) 122 mox.MoxTestBase.setUp(self)
92 123
93 def testInit(self):
94 self.mox.StubOutWithMock(cros_mark_as_stable._EBuild, '_ParseEBuildPath')
95
96 ebuild_path = '/overlay/cat/test_package/test_package-0.0.1-r1.ebuild'
97 cros_mark_as_stable._EBuild._ParseEBuildPath(
98 ebuild_path).AndReturn(['/overlay/cat/test_package-0.0.1',
99 '/overlay/cat/test_package',
100 1])
101 self.mox.StubOutWithMock(cros_mark_as_stable.fileinput, 'input')
102 mock_file = ['EAPI=2', 'CROS_WORKON_COMMIT=old_id',
103 'KEYWORDS=\"~x86 ~arm\"', 'src_unpack(){}']
104 cros_mark_as_stable.fileinput.input(ebuild_path).AndReturn(mock_file)
105
106 self.mox.ReplayAll()
107 ebuild = cros_mark_as_stable._EBuild(ebuild_path)
108 self.mox.VerifyAll()
109 self.assertEquals(ebuild.package, 'cat/test_package')
110 self.assertEquals(ebuild.ebuild_path, ebuild_path)
111 self.assertEquals(ebuild.ebuild_path_no_revision,
112 '/overlay/cat/test_package-0.0.1')
113 self.assertEquals(ebuild.ebuild_path_no_version,
114 '/overlay/cat/test_package')
115 self.assertEquals(ebuild.current_revision, 1)
116
117 def testParseEBuildPath(self): 124 def testParseEBuildPath(self):
118 # Test with ebuild with revision number. 125 # Test with ebuild with revision number.
119 no_rev, no_version, revision = cros_mark_as_stable._EBuild._ParseEBuildPath( 126 fake_ebuild_path = '/path/to/test_package/test_package-0.0.1-r1.ebuild'
120 '/path/test_package-0.0.1-r1.ebuild') 127 self.mox.StubOutWithMock(fileinput, 'input')
121 self.assertEquals(no_rev, '/path/test_package-0.0.1') 128 fileinput.input(fake_ebuild_path).AndReturn('')
122 self.assertEquals(no_version, '/path/test_package') 129 self.mox.ReplayAll()
123 self.assertEquals(revision, 1) 130 fake_ebuild = cros_mark_as_stable.EBuild(fake_ebuild_path)
131 self.mox.VerifyAll()
132 self.assertEquals(fake_ebuild.ebuild_path_no_revision,
133 '/path/to/test_package/test_package-0.0.1')
134 self.assertEquals(fake_ebuild.ebuild_path_no_version,
135 '/path/to/test_package/test_package')
136 self.assertEquals(fake_ebuild.current_revision, 1)
124 137
125 def testParseEBuildPathNoRevisionNumber(self): 138 def testParseEBuildPathNoRevisionNumber(self):
126 # Test with ebuild without revision number. 139 # Test with ebuild without revision number.
127 no_rev, no_version, revision = cros_mark_as_stable._EBuild._ParseEBuildPath( 140 fake_ebuild_path = '/path/to/test_package/test_package-9999.ebuild'
128 '/path/test_package-9999.ebuild') 141 self.mox.StubOutWithMock(fileinput, 'input')
129 self.assertEquals(no_rev, '/path/test_package-0.0.1') 142 fileinput.input(fake_ebuild_path).AndReturn('')
130 self.assertEquals(no_version, '/path/test_package') 143 self.mox.ReplayAll()
131 self.assertEquals(revision, 0) 144 fake_ebuild = cros_mark_as_stable.EBuild(fake_ebuild_path)
145 self.mox.VerifyAll()
146
147 self.assertEquals(fake_ebuild.ebuild_path_no_revision,
148 '/path/to/test_package/test_package-9999')
149 self.assertEquals(fake_ebuild.ebuild_path_no_version,
150 '/path/to/test_package/test_package')
151 self.assertEquals(fake_ebuild.current_revision, 0)
132 152
133 153
134 class EBuildStableMarkerTest(mox.MoxTestBase): 154 class EBuildStableMarkerTest(mox.MoxTestBase):
135 155
136 def setUp(self): 156 def setUp(self):
137 mox.MoxTestBase.setUp(self) 157 mox.MoxTestBase.setUp(self)
138 self.mox.StubOutWithMock(cros_mark_as_stable, '_SimpleRunCommand') 158 self.mox.StubOutWithMock(cros_mark_as_stable, '_SimpleRunCommand')
139 self.mox.StubOutWithMock(cros_mark_as_stable, 'RunCommand') 159 self.mox.StubOutWithMock(cros_mark_as_stable, 'RunCommand')
140 self.mox.StubOutWithMock(os, 'unlink') 160 self.mox.StubOutWithMock(os, 'unlink')
141 self.m_ebuild = self.mox.CreateMock(cros_mark_as_stable._EBuild) 161 self.m_ebuild = self.mox.CreateMock(cros_mark_as_stable.EBuild)
142 self.m_ebuild.is_stable = True 162 self.m_ebuild.is_stable = True
143 self.m_ebuild.package = 'test_package' 163 self.m_ebuild.package = 'test_package'
144 self.m_ebuild.current_revision = 1 164 self.m_ebuild.current_revision = 1
145 self.m_ebuild.ebuild_path_no_revision = '/path/test_package-0.0.1' 165 self.m_ebuild.ebuild_path_no_revision = '/path/test_package-0.0.1'
146 self.m_ebuild.ebuild_path_no_version = '/path/test_package' 166 self.m_ebuild.ebuild_path_no_version = '/path/test_package'
147 self.m_ebuild.ebuild_path = '/path/test_package-0.0.1-r1.ebuild' 167 self.m_ebuild.ebuild_path = '/path/test_package-0.0.1-r1.ebuild'
148 self.revved_ebuild_path = '/path/test_package-0.0.1-r2.ebuild' 168 self.revved_ebuild_path = '/path/test_package-0.0.1-r2.ebuild'
149 169
150 def testRevEBuild(self): 170 def testRevWorkOnEBuild(self):
151 self.mox.StubOutWithMock(cros_mark_as_stable.fileinput, 'input') 171 self.mox.StubOutWithMock(cros_mark_as_stable.fileinput, 'input')
152 self.mox.StubOutWithMock(cros_mark_as_stable.os.path, 'exists') 172 self.mox.StubOutWithMock(cros_mark_as_stable.os.path, 'exists')
153 self.mox.StubOutWithMock(cros_mark_as_stable.shutil, 'copyfile') 173 self.mox.StubOutWithMock(cros_mark_as_stable.shutil, 'copyfile')
154 m_file = self.mox.CreateMock(file) 174 m_file = self.mox.CreateMock(file)
155 175
156 # Prepare mock fileinput. This tests to make sure both the commit id 176 # Prepare mock fileinput. This tests to make sure both the commit id
157 # and keywords are changed correctly. 177 # and keywords are changed correctly.
158 mock_file = ['EAPI=2', 'CROS_WORKON_COMMIT=old_id', 178 mock_file = ['EAPI=2', 'CROS_WORKON_COMMIT=old_id',
159 'KEYWORDS=\"~x86 ~arm\"', 'src_unpack(){}'] 179 'KEYWORDS=\"~x86 ~arm\"', 'src_unpack(){}']
160 180
161 ebuild_9999 = self.m_ebuild.ebuild_path_no_version + '-9999.ebuild' 181 ebuild_9999 = self.m_ebuild.ebuild_path_no_version + '-9999.ebuild'
162 cros_mark_as_stable.os.path.exists(ebuild_9999).AndReturn(True) 182 cros_mark_as_stable.os.path.exists(ebuild_9999).AndReturn(True)
163 cros_mark_as_stable.shutil.copyfile(ebuild_9999, self.revved_ebuild_path) 183 cros_mark_as_stable.shutil.copyfile(ebuild_9999, self.revved_ebuild_path)
164 cros_mark_as_stable.fileinput.input(self.revved_ebuild_path, 184 cros_mark_as_stable.fileinput.input(self.revved_ebuild_path,
165 inplace=1).AndReturn(mock_file) 185 inplace=1).AndReturn(mock_file)
166 m_file.write('EAPI=2') 186 m_file.write('EAPI=2')
167 m_file.write('CROS_WORKON_COMMIT="my_id"\n') 187 m_file.write('CROS_WORKON_COMMIT="my_id"\n')
168 m_file.write('KEYWORDS="x86 arm"') 188 m_file.write('KEYWORDS="x86 arm"')
169 m_file.write('src_unpack(){}') 189 m_file.write('src_unpack(){}')
170 diff_cmd = ['diff', '-Bu', self.m_ebuild.ebuild_path, 190 diff_cmd = ['diff', '-Bu', self.m_ebuild.ebuild_path,
171 self.revved_ebuild_path] 191 self.revved_ebuild_path]
172 cros_mark_as_stable.RunCommand(diff_cmd, exit_code=True, 192 cros_mark_as_stable.RunCommand(diff_cmd, exit_code=True,
173 print_cmd=False, redirect_stderr=True, 193 print_cmd=False, redirect_stderr=True,
174 redirect_stdout=True).AndReturn(1) 194 redirect_stdout=True).AndReturn(1)
175 cros_mark_as_stable._SimpleRunCommand('git add ' + self.revved_ebuild_path) 195 cros_mark_as_stable._SimpleRunCommand('git add ' + self.revved_ebuild_path)
176 cros_mark_as_stable._SimpleRunCommand('git rm ' + self.m_ebuild.ebuild_path) 196 cros_mark_as_stable._SimpleRunCommand('git rm ' + self.m_ebuild.ebuild_path)
177 197
178 self.mox.ReplayAll() 198 self.mox.ReplayAll()
179 marker = cros_mark_as_stable.EBuildStableMarker(self.m_ebuild) 199 marker = cros_mark_as_stable.EBuildStableMarker(self.m_ebuild)
180 marker.RevEBuild('my_id', redirect_file=m_file) 200 marker.RevWorkOnEBuild('my_id', redirect_file=m_file)
181 self.mox.VerifyAll() 201 self.mox.VerifyAll()
182 202
183 def testRevUnchangedEBuild(self): 203 def testRevUnchangedEBuild(self):
184 self.mox.StubOutWithMock(cros_mark_as_stable.fileinput, 'input') 204 self.mox.StubOutWithMock(cros_mark_as_stable.fileinput, 'input')
185 self.mox.StubOutWithMock(cros_mark_as_stable.os.path, 'exists') 205 self.mox.StubOutWithMock(cros_mark_as_stable.os.path, 'exists')
186 self.mox.StubOutWithMock(cros_mark_as_stable.shutil, 'copyfile') 206 self.mox.StubOutWithMock(cros_mark_as_stable.shutil, 'copyfile')
187 m_file = self.mox.CreateMock(file) 207 m_file = self.mox.CreateMock(file)
188 208
189 # Prepare mock fileinput. This tests to make sure both the commit id 209 # Prepare mock fileinput. This tests to make sure both the commit id
190 # and keywords are changed correctly. 210 # and keywords are changed correctly.
(...skipping 11 matching lines...) Expand all
202 m_file.write('src_unpack(){}') 222 m_file.write('src_unpack(){}')
203 diff_cmd = ['diff', '-Bu', self.m_ebuild.ebuild_path, 223 diff_cmd = ['diff', '-Bu', self.m_ebuild.ebuild_path,
204 self.revved_ebuild_path] 224 self.revved_ebuild_path]
205 cros_mark_as_stable.RunCommand(diff_cmd, exit_code=True, 225 cros_mark_as_stable.RunCommand(diff_cmd, exit_code=True,
206 print_cmd=False, redirect_stderr=True, 226 print_cmd=False, redirect_stderr=True,
207 redirect_stdout=True).AndReturn(0) 227 redirect_stdout=True).AndReturn(0)
208 cros_mark_as_stable.os.unlink(self.revved_ebuild_path) 228 cros_mark_as_stable.os.unlink(self.revved_ebuild_path)
209 229
210 self.mox.ReplayAll() 230 self.mox.ReplayAll()
211 marker = cros_mark_as_stable.EBuildStableMarker(self.m_ebuild) 231 marker = cros_mark_as_stable.EBuildStableMarker(self.m_ebuild)
212 marker.RevEBuild('my_id', redirect_file=m_file) 232 marker.RevWorkOnEBuild('my_id', redirect_file=m_file)
213 self.mox.VerifyAll() 233 self.mox.VerifyAll()
214 234
215 def testRevMissingEBuild(self): 235 def testRevMissingEBuild(self):
216 self.mox.StubOutWithMock(cros_mark_as_stable.fileinput, 'input') 236 self.mox.StubOutWithMock(cros_mark_as_stable.fileinput, 'input')
217 self.mox.StubOutWithMock(cros_mark_as_stable.os.path, 'exists') 237 self.mox.StubOutWithMock(cros_mark_as_stable.os.path, 'exists')
218 self.mox.StubOutWithMock(cros_mark_as_stable.shutil, 'copyfile') 238 self.mox.StubOutWithMock(cros_mark_as_stable.shutil, 'copyfile')
219 self.mox.StubOutWithMock(cros_mark_as_stable, 'Die') 239 self.mox.StubOutWithMock(cros_mark_as_stable, 'Die')
220 m_file = self.mox.CreateMock(file) 240 m_file = self.mox.CreateMock(file)
221 241
222 # Prepare mock fileinput. This tests to make sure both the commit id 242 # Prepare mock fileinput. This tests to make sure both the commit id
223 # and keywords are changed correctly. 243 # and keywords are changed correctly.
224 mock_file = ['EAPI=2', 'CROS_WORKON_COMMIT=old_id', 244 mock_file = ['EAPI=2', 'CROS_WORKON_COMMIT=old_id',
225 'KEYWORDS=\"~x86 ~arm\"', 'src_unpack(){}'] 245 'KEYWORDS=\"~x86 ~arm\"', 'src_unpack(){}']
226 246
227 ebuild_9999 = self.m_ebuild.ebuild_path_no_version + '-9999.ebuild' 247 ebuild_9999 = self.m_ebuild.ebuild_path_no_version + '-9999.ebuild'
228 cros_mark_as_stable.os.path.exists(ebuild_9999).AndReturn(False) 248 cros_mark_as_stable.os.path.exists(ebuild_9999).AndReturn(False)
229 cros_mark_as_stable.Die("Missing 9999 ebuild: %s" % ebuild_9999) 249 cros_mark_as_stable.Die("Missing unstable ebuild: %s" % ebuild_9999)
230 cros_mark_as_stable.shutil.copyfile(ebuild_9999, self.revved_ebuild_path) 250 cros_mark_as_stable.shutil.copyfile(ebuild_9999, self.revved_ebuild_path)
231 cros_mark_as_stable.fileinput.input(self.revved_ebuild_path, 251 cros_mark_as_stable.fileinput.input(self.revved_ebuild_path,
232 inplace=1).AndReturn(mock_file) 252 inplace=1).AndReturn(mock_file)
233 m_file.write('EAPI=2') 253 m_file.write('EAPI=2')
234 m_file.write('CROS_WORKON_COMMIT="my_id"\n') 254 m_file.write('CROS_WORKON_COMMIT="my_id"\n')
235 m_file.write('KEYWORDS="x86 arm"') 255 m_file.write('KEYWORDS="x86 arm"')
236 m_file.write('src_unpack(){}') 256 m_file.write('src_unpack(){}')
237 diff_cmd = ['diff', '-Bu', self.m_ebuild.ebuild_path, 257 diff_cmd = ['diff', '-Bu', self.m_ebuild.ebuild_path,
238 self.revved_ebuild_path] 258 self.revved_ebuild_path]
239 cros_mark_as_stable.RunCommand(diff_cmd, exit_code=True, 259 cros_mark_as_stable.RunCommand(diff_cmd, exit_code=True,
240 print_cmd=False, redirect_stderr=True, 260 print_cmd=False, redirect_stderr=True,
241 redirect_stdout=True).AndReturn(1) 261 redirect_stdout=True).AndReturn(1)
242 cros_mark_as_stable._SimpleRunCommand('git add ' + self.revved_ebuild_path) 262 cros_mark_as_stable._SimpleRunCommand('git add ' + self.revved_ebuild_path)
243 cros_mark_as_stable._SimpleRunCommand('git rm ' + self.m_ebuild.ebuild_path) 263 cros_mark_as_stable._SimpleRunCommand('git rm ' + self.m_ebuild.ebuild_path)
244 264
245 self.mox.ReplayAll() 265 self.mox.ReplayAll()
246 marker = cros_mark_as_stable.EBuildStableMarker(self.m_ebuild) 266 marker = cros_mark_as_stable.EBuildStableMarker(self.m_ebuild)
247 marker.RevEBuild('my_id', redirect_file=m_file) 267 marker.RevWorkOnEBuild('my_id', redirect_file=m_file)
248 self.mox.VerifyAll() 268 self.mox.VerifyAll()
249 269
250 270
251 def testCommitChange(self): 271 def testCommitChange(self):
252 mock_message = 'Commit me' 272 mock_message = 'Commit me'
253 cros_mark_as_stable._SimpleRunCommand( 273 cros_mark_as_stable._SimpleRunCommand(
254 'git commit -am "%s"' % mock_message) 274 'git commit -am "%s"' % mock_message)
255 self.mox.ReplayAll() 275 self.mox.ReplayAll()
256 marker = cros_mark_as_stable.EBuildStableMarker(self.m_ebuild) 276 marker = cros_mark_as_stable.EBuildStableMarker(self.m_ebuild)
257 marker.CommitChange(mock_message) 277 marker.CommitChange(mock_message)
258 self.mox.VerifyAll() 278 self.mox.VerifyAll()
259 279
260 def testPushChange(self):
261 #cros_mark_as_stable._SimpleRunCommand('git push')
262 #self.mox.ReplayAll()
263 #marker = cros_mark_as_stable.EBuildStableMarker(self.m_ebuild)
264 #marker.PushChange()
265 #self.mox.VerifyAll()
266 pass
267
268 280
269 class _Package(object): 281 class _Package(object):
270 def __init__(self, package): 282 def __init__(self, package):
271 self.package = package 283 self.package = package
272 284
273 285
274 class BuildEBuildDictionaryTest(mox.MoxTestBase): 286 class BuildEBuildDictionaryTest(mox.MoxTestBase):
275 287
276 def setUp(self): 288 def setUp(self):
277 mox.MoxTestBase.setUp(self) 289 mox.MoxTestBase.setUp(self)
(...skipping 23 matching lines...) Expand all
301 cros_mark_as_stable._FindUprevCandidates([]).AndReturn(package) 313 cros_mark_as_stable._FindUprevCandidates([]).AndReturn(package)
302 self.mox.ReplayAll() 314 self.mox.ReplayAll()
303 cros_mark_as_stable._BuildEBuildDictionary(overlays, False, []) 315 cros_mark_as_stable._BuildEBuildDictionary(overlays, False, [])
304 self.assertEquals(len(overlays), 1) 316 self.assertEquals(len(overlays), 1)
305 self.assertEquals(overlays["/overlay"], []) 317 self.assertEquals(overlays["/overlay"], [])
306 self.mox.VerifyAll() 318 self.mox.VerifyAll()
307 319
308 320
309 if __name__ == '__main__': 321 if __name__ == '__main__':
310 unittest.main() 322 unittest.main()
OLDNEW
« cros_mark_as_stable.py ('K') | « cros_mark_as_stable.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698