OLD | NEW |
1 #!/usr/bin/python | 1 #!/usr/bin/python |
2 # Copyright (c) 2009 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2009 The Chromium 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 """Unit tests for gcl.py.""" | 6 """Unit tests for gcl.py.""" |
7 | 7 |
8 import unittest | 8 import unittest |
9 | 9 |
10 # Local imports | 10 # Local imports |
11 import gcl | 11 import gcl |
12 import super_mox | 12 import super_mox |
13 from super_mox import mox | 13 from super_mox import mox |
14 | 14 |
15 | 15 |
16 class GclTestsBase(super_mox.SuperMoxTestBase): | 16 class GclTestsBase(super_mox.SuperMoxTestBase): |
17 """Setups and tear downs the mocks but doesn't test anything as-is.""" | 17 """Setups and tear downs the mocks but doesn't test anything as-is.""" |
18 def setUp(self): | 18 def setUp(self): |
19 super_mox.SuperMoxTestBase.setUp(self) | 19 super_mox.SuperMoxTestBase.setUp(self) |
20 self.mox.StubOutWithMock(gcl, 'RunShell') | 20 self.mox.StubOutWithMock(gcl, 'RunShell') |
21 self.mox.StubOutWithMock(gcl.gclient, 'CaptureSVNInfo') | 21 self.mox.StubOutWithMock(gcl.gclient, 'CaptureSVNInfo') |
22 self.mox.StubOutWithMock(gcl, 'os') | |
23 self.mox.StubOutWithMock(gcl.os, 'getcwd') | 22 self.mox.StubOutWithMock(gcl.os, 'getcwd') |
| 23 self.mox.StubOutWithMock(gcl.os, 'chdir') |
| 24 self.mox.StubOutWithMock(gcl.os, 'close') |
| 25 self.mox.StubOutWithMock(gcl.os, 'remove') |
| 26 self.mox.StubOutWithMock(gcl.os, 'write') |
| 27 self.mox.StubOutWithMock(gcl.os.path, 'exists') |
| 28 self.mox.StubOutWithMock(gcl.os.path, 'isdir') |
| 29 self.mox.StubOutWithMock(gcl.os.path, 'isfile') |
| 30 self.mox.StubOutWithMock(gcl, 'tempfile') |
| 31 self.mox.StubOutWithMock(gcl.upload, 'RealMain') |
| 32 # These are not tested. |
| 33 self.mox.StubOutWithMock(gcl, 'ReadFile') |
| 34 self.mox.StubOutWithMock(gcl, 'WriteFile') |
24 | 35 |
25 | 36 |
26 class GclUnittest(GclTestsBase): | 37 class GclUnittest(GclTestsBase): |
27 """General gcl.py tests.""" | 38 """General gcl.py tests.""" |
28 def testMembersChanged(self): | 39 def testMembersChanged(self): |
| 40 self.mox.ReplayAll() |
29 members = [ | 41 members = [ |
30 'CODEREVIEW_SETTINGS', 'CODEREVIEW_SETTINGS_FILE', 'CPP_EXTENSIONS', | 42 'CODEREVIEW_SETTINGS', 'CODEREVIEW_SETTINGS_FILE', 'CPP_EXTENSIONS', |
31 'Change', 'ChangeInfo', 'Changes', 'Commit', 'DoPresubmitChecks', | 43 'Change', 'ChangeInfo', 'Changes', 'Commit', 'DoPresubmitChecks', |
32 'ErrorExit', 'FILES_CACHE', 'FilterFlag', 'GenerateChangeName', | 44 'ErrorExit', 'FILES_CACHE', 'FilterFlag', 'GenerateChangeName', |
33 'GenerateDiff', | 45 'GenerateDiff', |
34 'GetCacheDir', 'GetCachedFile', 'GetChangesDir', 'GetCLs', | 46 'GetCacheDir', 'GetCachedFile', 'GetChangesDir', 'GetCLs', |
35 'GetChangelistInfoFile', 'GetCodeReviewSetting', 'GetEditor', | 47 'GetChangelistInfoFile', 'GetCodeReviewSetting', 'GetEditor', |
36 'GetFilesNotInCL', 'GetInfoDir', 'GetIssueDescription', | 48 'GetFilesNotInCL', 'GetInfoDir', 'GetIssueDescription', |
37 'GetModifiedFiles', 'GetRepositoryRoot', | 49 'GetModifiedFiles', 'GetRepositoryRoot', |
38 'GetSVNFileProperty', 'Help', 'IGNORE_PATHS', 'IsSVNMoved', | 50 'GetSVNFileProperty', 'Help', 'IGNORE_PATHS', 'IsSVNMoved', |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
79 gcl.os.path.dirname(root_path), | 91 gcl.os.path.dirname(root_path), |
80 print_error=False).AndReturn(results2) | 92 print_error=False).AndReturn(results2) |
81 self.mox.ReplayAll() | 93 self.mox.ReplayAll() |
82 self.assertEquals(gcl.GetRepositoryRoot(), root_path) | 94 self.assertEquals(gcl.GetRepositoryRoot(), root_path) |
83 | 95 |
84 | 96 |
85 class ChangeInfoUnittest(GclTestsBase): | 97 class ChangeInfoUnittest(GclTestsBase): |
86 def setUp(self): | 98 def setUp(self): |
87 GclTestsBase.setUp(self) | 99 GclTestsBase.setUp(self) |
88 self.mox.StubOutWithMock(gcl, 'GetChangelistInfoFile') | 100 self.mox.StubOutWithMock(gcl, 'GetChangelistInfoFile') |
89 self.mox.StubOutWithMock(gcl.os.path, 'exists') | 101 self.mox.StubOutWithMock(gcl, 'GetRepositoryRoot') |
90 self.mox.StubOutWithMock(gcl, 'ReadFile') | |
91 self.mox.StubOutWithMock(gcl, 'WriteFile') | |
92 | 102 |
93 def testChangeInfoMembers(self): | 103 def testChangeInfoMembers(self): |
| 104 gcl.GetRepositoryRoot().AndReturn('prout') |
| 105 self.mox.ReplayAll() |
94 members = [ | 106 members = [ |
95 'CloseIssue', 'Delete', 'FileList', 'Load', 'MissingTests', 'Save', | 107 'CloseIssue', 'Delete', 'GetFiles', 'GetFileNames', 'GetLocalRoot', |
96 'UpdateRietveldDescription', 'description', 'files', 'issue', 'name', | 108 'Load', 'MissingTests', 'Save', 'UpdateRietveldDescription', |
| 109 'description', 'issue', 'name', |
97 'patch', 'patchset', | 110 'patch', 'patchset', |
98 ] | 111 ] |
99 # If this test fails, you should add the relevant test. | 112 # If this test fails, you should add the relevant test. |
100 self.compareMembers(gcl.ChangeInfo('', 0, 0, '', None), members) | 113 self.compareMembers(gcl.ChangeInfo('', 0, 0, '', None), members) |
101 | 114 |
102 def testChangeInfoBase(self): | 115 def testChangeInfoBase(self): |
103 files = [('M', 'foo'), ('A', 'bar')] | 116 files = [('M', 'foo'), ('A', 'bar')] |
| 117 gcl.GetRepositoryRoot().AndReturn('prout') |
104 self.mox.ReplayAll() | 118 self.mox.ReplayAll() |
105 o = gcl.ChangeInfo('name2', '42', '53', 'description2', files) | 119 o = gcl.ChangeInfo('name2', '42', '53', 'description2', files) |
106 self.assertEquals(o.name, 'name2') | 120 self.assertEquals(o.name, 'name2') |
107 self.assertEquals(o.issue, 42) | 121 self.assertEquals(o.issue, 42) |
108 self.assertEquals(o.patchset, 53) | 122 self.assertEquals(o.patchset, 53) |
109 self.assertEquals(o.description, 'description2') | 123 self.assertEquals(o.description, 'description2') |
110 self.assertEquals(o.files, files) | |
111 self.assertEquals(o.patch, None) | 124 self.assertEquals(o.patch, None) |
112 self.assertEquals(o.FileList(), ['foo', 'bar']) | 125 self.assertEquals(o.GetFileNames(), ['foo', 'bar']) |
| 126 self.assertEquals(o.GetFiles(), files) |
| 127 self.assertEquals(o.GetLocalRoot(), 'prout') |
113 | 128 |
114 def testLoadWithIssue(self): | 129 def testLoadWithIssue(self): |
115 description = ["This is some description.", "force an extra separator."] | 130 description = ["This is some description.", "force an extra separator."] |
116 gcl.GetChangelistInfoFile('bleh').AndReturn('bleeeh') | 131 gcl.GetChangelistInfoFile('bleh').AndReturn('bleeeh') |
117 gcl.os.path.exists('bleeeh').AndReturn(True) | 132 gcl.os.path.exists('bleeeh').AndReturn(True) |
118 gcl.ReadFile('bleeeh').AndReturn( | 133 gcl.ReadFile('bleeeh').AndReturn( |
119 gcl.ChangeInfo._SEPARATOR.join(["42,53", "G b.cc"] + description)) | 134 gcl.ChangeInfo._SEPARATOR.join(["42,53", "G b.cc"] + description)) |
| 135 gcl.GetRepositoryRoot().AndReturn('prout') |
120 self.mox.ReplayAll() | 136 self.mox.ReplayAll() |
121 | 137 |
122 change_info = gcl.ChangeInfo.Load('bleh', True, False) | 138 change_info = gcl.ChangeInfo.Load('bleh', True, False) |
123 self.assertEquals(change_info.name, 'bleh') | 139 self.assertEquals(change_info.name, 'bleh') |
124 self.assertEquals(change_info.issue, 42) | 140 self.assertEquals(change_info.issue, 42) |
125 self.assertEquals(change_info.patchset, 53) | 141 self.assertEquals(change_info.patchset, 53) |
126 self.assertEquals(change_info.description, | 142 self.assertEquals(change_info.description, |
127 gcl.ChangeInfo._SEPARATOR.join(description)) | 143 gcl.ChangeInfo._SEPARATOR.join(description)) |
128 self.assertEquals(change_info.files, [('G ', 'b.cc')]) | 144 self.assertEquals(change_info.GetFiles(), [('G ', 'b.cc')]) |
129 | 145 |
130 def testLoadEmpty(self): | 146 def testLoadEmpty(self): |
131 gcl.GetChangelistInfoFile('bleh').AndReturn('bleeeh') | 147 gcl.GetChangelistInfoFile('bleh').AndReturn('bleeeh') |
132 gcl.os.path.exists('bleeeh').AndReturn(True) | 148 gcl.os.path.exists('bleeeh').AndReturn(True) |
133 gcl.ReadFile('bleeeh').AndReturn( | 149 gcl.ReadFile('bleeeh').AndReturn( |
134 gcl.ChangeInfo._SEPARATOR.join(["", "", ""])) | 150 gcl.ChangeInfo._SEPARATOR.join(["", "", ""])) |
| 151 gcl.GetRepositoryRoot().AndReturn('prout') |
135 self.mox.ReplayAll() | 152 self.mox.ReplayAll() |
136 | 153 |
137 change_info = gcl.ChangeInfo.Load('bleh', True, False) | 154 change_info = gcl.ChangeInfo.Load('bleh', True, False) |
138 self.assertEquals(change_info.name, 'bleh') | 155 self.assertEquals(change_info.name, 'bleh') |
139 self.assertEquals(change_info.issue, 0) | 156 self.assertEquals(change_info.issue, 0) |
140 self.assertEquals(change_info.patchset, 0) | 157 self.assertEquals(change_info.patchset, 0) |
141 self.assertEquals(change_info.description, "") | 158 self.assertEquals(change_info.description, "") |
142 self.assertEquals(change_info.files, []) | 159 self.assertEquals(change_info.GetFiles(), []) |
143 | 160 |
144 def testSaveEmpty(self): | 161 def testSaveEmpty(self): |
145 gcl.GetChangelistInfoFile('').AndReturn('foo') | 162 gcl.GetChangelistInfoFile('').AndReturn('foo') |
146 gcl.WriteFile('foo', gcl.ChangeInfo._SEPARATOR.join(['0, 0', '', ''])) | 163 gcl.WriteFile('foo', gcl.ChangeInfo._SEPARATOR.join(['0, 0', '', ''])) |
| 164 gcl.GetRepositoryRoot().AndReturn('prout') |
147 self.mox.ReplayAll() | 165 self.mox.ReplayAll() |
148 change_info = gcl.ChangeInfo('', 0, 0, '', None) | 166 change_info = gcl.ChangeInfo('', 0, 0, '', None) |
149 change_info.Save() | 167 change_info.Save() |
150 | 168 |
151 | 169 |
152 class UploadCLUnittest(GclTestsBase): | 170 class UploadCLUnittest(GclTestsBase): |
153 def setUp(self): | 171 def setUp(self): |
154 GclTestsBase.setUp(self) | 172 GclTestsBase.setUp(self) |
155 self.mox.StubOutWithMock(gcl.os, 'chdir') | |
156 self.mox.StubOutWithMock(gcl.os, 'close') | |
157 self.mox.StubOutWithMock(gcl.os, 'remove') | |
158 self.mox.StubOutWithMock(gcl.os, 'write') | |
159 self.mox.StubOutWithMock(gcl, 'tempfile') | |
160 self.mox.StubOutWithMock(gcl.upload, 'RealMain') | |
161 self.mox.StubOutWithMock(gcl, 'DoPresubmitChecks') | 173 self.mox.StubOutWithMock(gcl, 'DoPresubmitChecks') |
162 self.mox.StubOutWithMock(gcl, 'GenerateDiff') | 174 self.mox.StubOutWithMock(gcl, 'GenerateDiff') |
163 self.mox.StubOutWithMock(gcl, 'GetCodeReviewSetting') | 175 self.mox.StubOutWithMock(gcl, 'GetCodeReviewSetting') |
164 self.mox.StubOutWithMock(gcl, 'GetRepositoryRoot') | 176 self.mox.StubOutWithMock(gcl, 'GetRepositoryRoot') |
165 self.mox.StubOutWithMock(gcl, 'SendToRietveld') | 177 self.mox.StubOutWithMock(gcl, 'SendToRietveld') |
166 self.mox.StubOutWithMock(gcl, 'TryChange') | 178 self.mox.StubOutWithMock(gcl, 'TryChange') |
167 | 179 |
168 def testNew(self): | 180 def testNew(self): |
169 change_info = gcl.ChangeInfo('naame', 1, 0, 'deescription', | 181 change_info = self.mox.CreateMock(gcl.ChangeInfo) |
170 ['aa', 'bb']) | 182 change_info.name = 'naame' |
171 self.mox.StubOutWithMock(change_info, 'Save') | 183 change_info.issue = 1 |
| 184 change_info.patchset = 0 |
| 185 change_info.description = 'deescription', |
| 186 change_info.files = [('A', 'aa'), ('M', 'bb')] |
| 187 change_info.patch = None |
| 188 files = [item[1] for item in change_info.files] |
172 args = ['--foo=bar'] | 189 args = ['--foo=bar'] |
173 change_info.Save() | |
174 gcl.DoPresubmitChecks(change_info, False, True).AndReturn(True) | 190 gcl.DoPresubmitChecks(change_info, False, True).AndReturn(True) |
175 gcl.GetCodeReviewSetting('CODE_REVIEW_SERVER').AndReturn('my_server') | 191 gcl.GetCodeReviewSetting('CODE_REVIEW_SERVER').AndReturn('my_server') |
176 gcl.os.getcwd().AndReturn('somewhere') | 192 gcl.os.getcwd().AndReturn('somewhere') |
177 gcl.os.chdir(gcl.GetRepositoryRoot().AndReturn(None)) | 193 change_info.GetFiles().AndReturn(change_info.files) |
178 gcl.GenerateDiff(change_info.FileList()) | 194 change_info.GetLocalRoot().AndReturn('proout') |
| 195 gcl.os.chdir('proout') |
| 196 change_info.GetFileNames().AndReturn(files) |
| 197 gcl.GenerateDiff(files) |
179 gcl.upload.RealMain(['upload.py', '-y', '--server=my_server', '--foo=bar', | 198 gcl.upload.RealMain(['upload.py', '-y', '--server=my_server', '--foo=bar', |
180 "--message=''", '--issue=1'], change_info.patch).AndReturn(("1", | 199 "--message=''", '--issue=1'], change_info.patch).AndReturn(("1", |
181 "2")) | 200 "2")) |
182 gcl.SendToRietveld("/lint/issue%s_%s" % ('1', '2'), timeout=0.5) | 201 gcl.SendToRietveld("/lint/issue%s_%s" % ('1', '2'), timeout=0.5) |
183 gcl.GetCodeReviewSetting('TRY_ON_UPLOAD').AndReturn('True') | 202 gcl.GetCodeReviewSetting('TRY_ON_UPLOAD').AndReturn('True') |
184 gcl.TryChange(change_info, [], swallow_exception=True) | 203 gcl.TryChange(change_info, [], swallow_exception=True) |
185 gcl.os.chdir('somewhere') | 204 gcl.os.chdir('somewhere') |
| 205 change_info.Save() |
186 self.mox.ReplayAll() | 206 self.mox.ReplayAll() |
| 207 |
187 gcl.UploadCL(change_info, args) | 208 gcl.UploadCL(change_info, args) |
188 | 209 |
189 def testServerOverride(self): | 210 def testServerOverride(self): |
190 change_info = gcl.ChangeInfo('naame', 0, 0, 'deescription', | 211 change_info = gcl.ChangeInfo('naame', 0, 0, 'deescription', |
191 ['aa', 'bb']) | 212 [('A', 'aa'), ('M', 'bb')]) |
192 change_info.Save = self.mox.CreateMockAnything() | 213 self.mox.StubOutWithMock(change_info, 'Save') |
193 args = ['--server=a', '--no_watchlists'] | 214 args = ['--server=a', '--no_watchlists'] |
194 change_info.Save() | 215 change_info.Save() |
195 gcl.DoPresubmitChecks(change_info, False, True).AndReturn(True) | 216 gcl.DoPresubmitChecks(change_info, False, True).AndReturn(True) |
196 gcl.GetCodeReviewSetting('CODE_REVIEW_SERVER').AndReturn('my_server') | 217 gcl.GetCodeReviewSetting('CODE_REVIEW_SERVER').AndReturn('my_server') |
197 gcl.tempfile.mkstemp(text=True).AndReturn((42, 'descfile')) | 218 gcl.tempfile.mkstemp(text=True).AndReturn((42, 'descfile')) |
198 gcl.os.write(42, change_info.description) | 219 gcl.os.write(42, change_info.description) |
199 gcl.os.close(42) | 220 gcl.os.close(42) |
200 gcl.GetCodeReviewSetting('CC_LIST') | 221 gcl.GetCodeReviewSetting('CC_LIST') |
201 gcl.os.getcwd().AndReturn('somewhere') | 222 gcl.os.getcwd().AndReturn('somewhere') |
202 gcl.os.chdir(gcl.GetRepositoryRoot().AndReturn(None)) | 223 gcl.os.chdir(change_info.GetLocalRoot()) |
203 gcl.GenerateDiff(change_info.FileList()) | 224 gcl.GenerateDiff(change_info.GetFileNames()) |
204 gcl.upload.RealMain(['upload.py', '-y', '--server=my_server', '--server=a', | 225 gcl.upload.RealMain(['upload.py', '-y', '--server=my_server', '--server=a', |
205 "--description_file=descfile", | 226 "--description_file=descfile", |
206 "--message=deescription"], change_info.patch).AndReturn(("1", "2")) | 227 "--message=deescription"], change_info.patch).AndReturn(("1", "2")) |
207 gcl.os.remove('descfile') | 228 gcl.os.remove('descfile') |
208 gcl.SendToRietveld("/lint/issue%s_%s" % ('1', '2'), timeout=0.5) | 229 gcl.SendToRietveld("/lint/issue%s_%s" % ('1', '2'), timeout=0.5) |
209 gcl.os.chdir('somewhere') | 230 gcl.os.chdir('somewhere') |
210 self.mox.ReplayAll() | 231 self.mox.ReplayAll() |
211 | 232 |
| 233 # To balance out the call in gcl.ChangeInfo.__init__(). |
| 234 gcl.GetRepositoryRoot() |
212 gcl.UploadCL(change_info, args) | 235 gcl.UploadCL(change_info, args) |
213 | 236 |
214 def testNoTry(self): | 237 def testNoTry(self): |
215 change_info = gcl.ChangeInfo('naame', 0, 0, 'deescription', | 238 change_info = gcl.ChangeInfo('naame', 0, 0, 'deescription', |
216 ['aa', 'bb']) | 239 [('A', 'aa'), ('M', 'bb')]) |
217 change_info.Save = self.mox.CreateMockAnything() | 240 change_info.Save = self.mox.CreateMockAnything() |
218 args = ['--no-try', '--no_watchlists'] | 241 args = ['--no-try', '--no_watchlists'] |
219 change_info.Save() | 242 change_info.Save() |
220 gcl.DoPresubmitChecks(change_info, False, True).AndReturn(True) | 243 gcl.DoPresubmitChecks(change_info, False, True).AndReturn(True) |
221 gcl.GetCodeReviewSetting('CODE_REVIEW_SERVER').AndReturn('my_server') | 244 gcl.GetCodeReviewSetting('CODE_REVIEW_SERVER').AndReturn('my_server') |
222 gcl.tempfile.mkstemp(text=True).AndReturn((42, 'descfile')) | 245 gcl.tempfile.mkstemp(text=True).AndReturn((42, 'descfile')) |
223 gcl.os.write(42, change_info.description) | 246 gcl.os.write(42, change_info.description) |
224 gcl.os.close(42) | 247 gcl.os.close(42) |
225 gcl.GetCodeReviewSetting('CC_LIST') | 248 gcl.GetCodeReviewSetting('CC_LIST') |
226 gcl.os.getcwd().AndReturn('somewhere') | 249 gcl.os.getcwd().AndReturn('somewhere') |
227 gcl.os.chdir(gcl.GetRepositoryRoot().AndReturn(None)) | 250 gcl.os.chdir(change_info.GetLocalRoot()) |
228 gcl.GenerateDiff(change_info.FileList()) | 251 gcl.GenerateDiff(change_info.GetFileNames()) |
229 gcl.upload.RealMain(['upload.py', '-y', '--server=my_server', | 252 gcl.upload.RealMain(['upload.py', '-y', '--server=my_server', |
230 "--description_file=descfile", | 253 "--description_file=descfile", |
231 "--message=deescription"], change_info.patch).AndReturn(("1", "2")) | 254 "--message=deescription"], change_info.patch).AndReturn(("1", "2")) |
232 gcl.os.remove('descfile') | 255 gcl.os.remove('descfile') |
233 gcl.SendToRietveld("/lint/issue%s_%s" % ('1', '2'), timeout=0.5) | 256 gcl.SendToRietveld("/lint/issue%s_%s" % ('1', '2'), timeout=0.5) |
234 gcl.os.chdir('somewhere') | 257 gcl.os.chdir('somewhere') |
235 self.mox.ReplayAll() | 258 self.mox.ReplayAll() |
236 | 259 |
| 260 # To balance out the call in gcl.ChangeInfo.__init__(). |
| 261 gcl.GetRepositoryRoot() |
237 gcl.UploadCL(change_info, args) | 262 gcl.UploadCL(change_info, args) |
238 | 263 |
239 def testNormal(self): | 264 def testNormal(self): |
240 change_info = gcl.ChangeInfo('naame', 0, 0, 'deescription', | 265 change_info = gcl.ChangeInfo('naame', 0, 0, 'deescription', |
241 ['aa', 'bb']) | 266 ['aa', 'bb']) |
242 self.mox.StubOutWithMock(change_info, 'Save') | 267 self.mox.StubOutWithMock(change_info, 'Save') |
243 args = ['--no_watchlists'] | 268 args = ['--no_watchlists'] |
244 change_info.Save() | 269 change_info.Save() |
245 gcl.DoPresubmitChecks(change_info, False, True).AndReturn(True) | 270 gcl.DoPresubmitChecks(change_info, False, True).AndReturn(True) |
246 gcl.GetCodeReviewSetting('CODE_REVIEW_SERVER').AndReturn('my_server') | 271 gcl.GetCodeReviewSetting('CODE_REVIEW_SERVER').AndReturn('my_server') |
247 gcl.tempfile.mkstemp(text=True).AndReturn((42, 'descfile')) | 272 gcl.tempfile.mkstemp(text=True).AndReturn((42, 'descfile')) |
248 gcl.os.write(42, change_info.description) | 273 gcl.os.write(42, change_info.description) |
249 gcl.os.close(42) | 274 gcl.os.close(42) |
250 gcl.GetCodeReviewSetting('CC_LIST') | 275 gcl.GetCodeReviewSetting('CC_LIST') |
251 gcl.os.getcwd().AndReturn('somewhere') | 276 gcl.os.getcwd().AndReturn('somewhere') |
252 gcl.os.chdir(gcl.GetRepositoryRoot().AndReturn(None)) | 277 gcl.os.chdir(change_info.GetLocalRoot()) |
253 gcl.GenerateDiff(change_info.FileList()) | 278 gcl.GenerateDiff(change_info.GetFileNames()) |
254 gcl.upload.RealMain(['upload.py', '-y', '--server=my_server', | 279 gcl.upload.RealMain(['upload.py', '-y', '--server=my_server', |
255 "--description_file=descfile", | 280 "--description_file=descfile", |
256 "--message=deescription"], change_info.patch).AndReturn(("1", "2")) | 281 "--message=deescription"], change_info.patch).AndReturn(("1", "2")) |
257 gcl.os.remove('descfile') | 282 gcl.os.remove('descfile') |
258 gcl.SendToRietveld("/lint/issue%s_%s" % ('1', '2'), timeout=0.5) | 283 gcl.SendToRietveld("/lint/issue%s_%s" % ('1', '2'), timeout=0.5) |
259 gcl.GetCodeReviewSetting('TRY_ON_UPLOAD').AndReturn('True') | 284 gcl.GetCodeReviewSetting('TRY_ON_UPLOAD').AndReturn('True') |
260 gcl.TryChange(change_info, [], swallow_exception=True) | 285 gcl.TryChange(change_info, [], swallow_exception=True) |
261 gcl.os.chdir('somewhere') | 286 gcl.os.chdir('somewhere') |
262 self.mox.ReplayAll() | 287 self.mox.ReplayAll() |
263 | 288 |
| 289 # To balance out the call in gcl.ChangeInfo.__init__(). |
| 290 gcl.GetRepositoryRoot() |
264 gcl.UploadCL(change_info, args) | 291 gcl.UploadCL(change_info, args) |
265 self.assertEquals(change_info.issue, 1) | 292 self.assertEquals(change_info.issue, 1) |
266 self.assertEquals(change_info.patchset, 2) | 293 self.assertEquals(change_info.patchset, 2) |
267 | 294 |
268 | 295 |
269 if __name__ == '__main__': | 296 if __name__ == '__main__': |
270 unittest.main() | 297 unittest.main() |
OLD | NEW |