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

Side by Side Diff: tests/gcl_unittest.py

Issue 13800021: Update the R= line with the actual list of reviewers that approved the CL. (Closed) Base URL: https://chromium.googlesource.com/chromium/tools/depot_tools.git@3_gcl_refactor
Patch Set: rebase Created 7 years, 8 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 unified diff | Download patch
« no previous file with comments | « git_cl.py ('k') | tests/git_cl_test.py » ('j') | 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/env python 1 #!/usr/bin/env python
2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. 2 # Copyright (c) 2012 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 # pylint: disable=E1103,E1101,E1120 8 # pylint: disable=E1103,E1101,E1120
9 9
10 import os 10 import os
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after
185 class ChangeInfoUnittest(GclTestsBase): 185 class ChangeInfoUnittest(GclTestsBase):
186 def setUp(self): 186 def setUp(self):
187 GclTestsBase.setUp(self) 187 GclTestsBase.setUp(self)
188 self.mox.StubOutWithMock(gcl, 'GetChangelistInfoFile') 188 self.mox.StubOutWithMock(gcl, 'GetChangelistInfoFile')
189 self.mox.StubOutWithMock(gcl, 'GetRepositoryRoot') 189 self.mox.StubOutWithMock(gcl, 'GetRepositoryRoot')
190 190
191 def testChangeInfoMembers(self): 191 def testChangeInfoMembers(self):
192 self.mox.ReplayAll() 192 self.mox.ReplayAll()
193 members = [ 193 members = [
194 'AddComment', 'CloseIssue', 'Delete', 'Exists', 'GetFiles', 194 'AddComment', 'CloseIssue', 'Delete', 'Exists', 'GetFiles',
195 'GetFileNames', 'GetLocalRoot', 'GetIssueDescription', 'Load', 195 'GetApprovingReviewers', 'GetFileNames', 'GetIssueDescription',
196 'GetLocalRoot', 'Load',
196 'MissingTests', 'NeedsUpload', 'PrimeLint', 'RpcServer', 'Save', 197 'MissingTests', 'NeedsUpload', 'PrimeLint', 'RpcServer', 'Save',
197 'SendToRietveld', 198 'SendToRietveld',
198 'SEPARATOR', 199 'SEPARATOR',
199 'UpdateDescriptionFromIssue', 'UpdateRietveldDescription', 200 'UpdateDescriptionFromIssue', 'UpdateRietveldDescription',
200 'append_footer', 201 'append_footer',
201 'description', 'force_description', 'get_reviewers', 'issue', 'name', 202 'description', 'force_description', 'get_reviewers', 'issue', 'name',
202 'needs_upload', 'patch', 'patchset', 'rietveld', 203 'needs_upload', 'patch', 'patchset', 'rietveld', 'update_reviewers',
203 ] 204 ]
204 # If this test fails, you should add the relevant test. 205 # If this test fails, you should add the relevant test.
205 self.compareMembers( 206 self.compareMembers(
206 gcl.ChangeInfo('', 0, 0, '', None, self.fake_root_dir, 'foo', False), 207 gcl.ChangeInfo('', 0, 0, '', None, self.fake_root_dir, 'foo', False),
207 members) 208 members)
208 209
209 def testChangeInfoBase(self): 210 def testChangeInfoBase(self):
210 files = [('M', 'foo'), ('A', 'bar')] 211 files = [('M', 'foo'), ('A', 'bar')]
211 self.mox.ReplayAll() 212 self.mox.ReplayAll()
212 o = gcl.ChangeInfo( 213 o = gcl.ChangeInfo(
(...skipping 356 matching lines...) Expand 10 before | Expand all | Expand 10 after
569 retval = gcl.CMDcommit(['naame']) 570 retval = gcl.CMDcommit(['naame'])
570 571
571 self.assertEquals(retval, 1) 572 self.assertEquals(retval, 1)
572 573
573 def testPresubmitSucceeds(self): 574 def testPresubmitSucceeds(self):
574 change_info = self.mockLoad() 575 change_info = self.mockLoad()
575 self.mockPresubmit(change_info, fail=False) 576 self.mockPresubmit(change_info, fail=False)
576 self.mockCommit( 577 self.mockCommit(
577 change_info, 'deescription\n\nReview URL: https://my_server/1', '') 578 change_info, 'deescription\n\nReview URL: https://my_server/1', '')
578 change_info.UpdateDescriptionFromIssue() 579 change_info.UpdateDescriptionFromIssue()
580 change_info.GetApprovingReviewers().AndReturn(['a@c'])
581 change_info.update_reviewers(['a@c'])
579 self.mox.ReplayAll() 582 self.mox.ReplayAll()
580 583
581 retval = gcl.CMDcommit(['naame']) 584 retval = gcl.CMDcommit(['naame'])
582 585
583 self.assertEquals(retval, 0) 586 self.assertEquals(retval, 0)
584 self.assertEquals(change_info.description, 'deescription') 587 self.assertEquals(change_info.description, 'deescription')
585 # pylint: disable=W0212 588 # pylint: disable=W0212
586 self.assertFalse(change_info._deleted) 589 self.assertFalse(change_info._deleted)
587 self.assertFalse(change_info._closed) 590 self.assertFalse(change_info._closed)
588 591
589 def testPresubmitSucceedsWithCommittedMessage(self): 592 def testPresubmitSucceedsWithCommittedMessage(self):
590 change_info = self.mockLoad() 593 change_info = self.mockLoad()
591 self.mockPresubmit(change_info, fail=False) 594 self.mockPresubmit(change_info, fail=False)
592 self.mockCommit( 595 self.mockCommit(
593 change_info, 596 change_info,
594 'deescription\n\nReview URL: https://my_server/1', 597 'deescription\n\nReview URL: https://my_server/1',
595 '\nCommitted revision 12345') 598 '\nCommitted revision 12345')
596 change_info.UpdateDescriptionFromIssue() 599 change_info.UpdateDescriptionFromIssue()
600 change_info.GetApprovingReviewers().AndReturn(['a@c'])
601 change_info.update_reviewers(['a@c'])
597 change_info.append_footer('Committed: http://view/12345') 602 change_info.append_footer('Committed: http://view/12345')
598 self.mox.ReplayAll() 603 self.mox.ReplayAll()
599 604
600 retval = gcl.CMDcommit(['naame']) 605 retval = gcl.CMDcommit(['naame'])
601 self.assertEquals(retval, 0) 606 self.assertEquals(retval, 0)
602 # This is because append_footer is mocked. 607 # This is because append_footer is mocked.
603 self.assertEquals(change_info.description, 'deescription') 608 self.assertEquals(change_info.description, 'deescription')
604 # pylint: disable=W0212 609 # pylint: disable=W0212
605 self.assertTrue(change_info._deleted) 610 self.assertTrue(change_info._deleted)
606 self.assertTrue(change_info._closed) 611 self.assertTrue(change_info._closed)
607 self.assertEqual( 612 self.assertEqual(
608 change_info._comments_added, 613 change_info._comments_added,
609 ["Committed patchset #1 manually as r12345 (presubmit successful)."]) 614 ["Committed patchset #1 manually as r12345 (presubmit successful)."])
610 615
611 616
612 if __name__ == '__main__': 617 if __name__ == '__main__':
613 import unittest 618 import unittest
614 unittest.main() 619 unittest.main()
OLDNEW
« no previous file with comments | « git_cl.py ('k') | tests/git_cl_test.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698