OLD | NEW |
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 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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', | 195 'GetFileNames', 'GetLocalRoot', |
196 'Load', | 196 'GetIssueReviewers', 'Load', |
197 'MissingTests', 'NeedsUpload', 'PrimeLint', 'RpcServer', 'Save', | 197 'MissingTests', 'NeedsUpload', 'PrimeLint', 'RpcServer', 'Save', |
198 'SendToRietveld', | 198 'SendToRietveld', |
199 'SEPARATOR', | 199 'SEPARATOR', |
200 'UpdateDescriptionFromIssue', 'UpdateRietveldDescription', | 200 'UpdateDescriptionFromIssue', 'UpdateRietveldDescription', |
201 'append_line', | 201 'append_line', |
202 'description', 'force_description', 'get_reviewers', 'issue', 'name', | 202 'description', 'force_description', 'get_reviewers', 'issue', 'name', |
203 'needs_upload', 'patch', 'patchset', 'rietveld', | 203 'needs_upload', 'patch', 'patchset', 'rietveld', 'update_reviewers', |
204 ] | 204 ] |
205 # If this test fails, you should add the relevant test. | 205 # If this test fails, you should add the relevant test. |
206 self.compareMembers( | 206 self.compareMembers( |
207 gcl.ChangeInfo('', 0, 0, '', None, self.fake_root_dir, 'foo', False), | 207 gcl.ChangeInfo('', 0, 0, '', None, self.fake_root_dir, 'foo', False), |
208 members) | 208 members) |
209 | 209 |
210 def testChangeInfoBase(self): | 210 def testChangeInfoBase(self): |
211 files = [('M', 'foo'), ('A', 'bar')] | 211 files = [('M', 'foo'), ('A', 'bar')] |
212 self.mox.ReplayAll() | 212 self.mox.ReplayAll() |
213 o = gcl.ChangeInfo( | 213 o = gcl.ChangeInfo( |
(...skipping 356 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
570 retval = gcl.CMDcommit(['naame']) | 570 retval = gcl.CMDcommit(['naame']) |
571 | 571 |
572 self.assertEquals(retval, 1) | 572 self.assertEquals(retval, 1) |
573 | 573 |
574 def testPresubmitSucceeds(self): | 574 def testPresubmitSucceeds(self): |
575 change_info = self.mockLoad() | 575 change_info = self.mockLoad() |
576 self.mockPresubmit(change_info, fail=False) | 576 self.mockPresubmit(change_info, fail=False) |
577 self.mockCommit( | 577 self.mockCommit( |
578 change_info, 'deescription\n\nReview URL: https://my_server/1', '') | 578 change_info, 'deescription\n\nReview URL: https://my_server/1', '') |
579 change_info.UpdateDescriptionFromIssue() | 579 change_info.UpdateDescriptionFromIssue() |
| 580 change_info.GetIssueReviewers().AndReturn(['a@c']) |
| 581 change_info.update_reviewers('a@c') |
580 self.mox.ReplayAll() | 582 self.mox.ReplayAll() |
581 | 583 |
582 retval = gcl.CMDcommit(['naame']) | 584 retval = gcl.CMDcommit(['naame']) |
583 | 585 |
584 self.assertEquals(retval, 0) | 586 self.assertEquals(retval, 0) |
585 self.assertEquals(change_info.description, 'deescription') | 587 self.assertEquals(change_info.description, 'deescription') |
586 # pylint: disable=W0212 | 588 # pylint: disable=W0212 |
587 self.assertFalse(change_info._deleted) | 589 self.assertFalse(change_info._deleted) |
588 self.assertFalse(change_info._closed) | 590 self.assertFalse(change_info._closed) |
589 | 591 |
590 def testPresubmitSucceedsWithCommittedMessage(self): | 592 def testPresubmitSucceedsWithCommittedMessage(self): |
591 change_info = self.mockLoad() | 593 change_info = self.mockLoad() |
592 self.mockPresubmit(change_info, fail=False) | 594 self.mockPresubmit(change_info, fail=False) |
593 self.mockCommit( | 595 self.mockCommit( |
594 change_info, | 596 change_info, |
595 'deescription\n\nReview URL: https://my_server/1', | 597 'deescription\n\nReview URL: https://my_server/1', |
596 '\nCommitted revision 12345') | 598 '\nCommitted revision 12345') |
597 change_info.UpdateDescriptionFromIssue() | 599 change_info.UpdateDescriptionFromIssue() |
| 600 change_info.GetIssueReviewers().AndReturn(['a@c']) |
| 601 change_info.update_reviewers('a@c') |
598 change_info.append_line('Committed: http://view/12345') | 602 change_info.append_line('Committed: http://view/12345') |
599 self.mox.ReplayAll() | 603 self.mox.ReplayAll() |
600 | 604 |
601 retval = gcl.CMDcommit(['naame']) | 605 retval = gcl.CMDcommit(['naame']) |
602 self.assertEquals(retval, 0) | 606 self.assertEquals(retval, 0) |
603 # This is because append_line is mocked. | 607 # This is because append_line is mocked. |
604 self.assertEquals(change_info.description, 'deescription') | 608 self.assertEquals(change_info.description, 'deescription') |
605 # pylint: disable=W0212 | 609 # pylint: disable=W0212 |
606 self.assertTrue(change_info._deleted) | 610 self.assertTrue(change_info._deleted) |
607 self.assertTrue(change_info._closed) | 611 self.assertTrue(change_info._closed) |
608 self.assertEqual( | 612 self.assertEqual( |
609 change_info._comments_added, | 613 change_info._comments_added, |
610 ["Committed patchset #1 manually as r12345 (presubmit successful)."]) | 614 ["Committed patchset #1 manually as r12345 (presubmit successful)."]) |
611 | 615 |
612 | 616 |
613 if __name__ == '__main__': | 617 if __name__ == '__main__': |
614 import unittest | 618 import unittest |
615 unittest.main() | 619 unittest.main() |
OLD | NEW |