| 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 19 matching lines...) Expand all Loading... |
| 30 self.mox.StubOutWithMock(gcl.upload, 'RealMain') | 30 self.mox.StubOutWithMock(gcl.upload, 'RealMain') |
| 31 self.mox.StubOutWithMock(gcl.gclient_utils, 'FileRead') | 31 self.mox.StubOutWithMock(gcl.gclient_utils, 'FileRead') |
| 32 self.mox.StubOutWithMock(gcl.gclient_utils, 'FileWrite') | 32 self.mox.StubOutWithMock(gcl.gclient_utils, 'FileWrite') |
| 33 gcl.REPOSITORY_ROOT = None | 33 gcl.REPOSITORY_ROOT = None |
| 34 self.old_review_settings = gcl.CODEREVIEW_SETTINGS | 34 self.old_review_settings = gcl.CODEREVIEW_SETTINGS |
| 35 self.assertEquals(gcl.CODEREVIEW_SETTINGS, {}) | 35 self.assertEquals(gcl.CODEREVIEW_SETTINGS, {}) |
| 36 | 36 |
| 37 def tearDown(self): | 37 def tearDown(self): |
| 38 gcl.CODEREVIEW_SETTINGS = self.old_review_settings | 38 gcl.CODEREVIEW_SETTINGS = self.old_review_settings |
| 39 | 39 |
| 40 def fakeChange(self, files=None): | 40 def fakeChange(self, files=None): # pylint: disable=R0201 |
| 41 if files == None: | 41 if files == None: |
| 42 files = [('A', 'aa'), ('M', 'bb')] | 42 files = [('A', 'aa'), ('M', 'bb')] |
| 43 | 43 |
| 44 change_info = self.mox.CreateMock(gcl.ChangeInfo) | 44 change_info = self.mox.CreateMock(gcl.ChangeInfo) |
| 45 change_info.name = 'naame' | 45 change_info.name = 'naame' |
| 46 change_info.issue = 1 | 46 change_info.issue = 1 |
| 47 change_info.patchset = 0 | 47 change_info.patchset = 0 |
| 48 change_info.description = 'deescription' | 48 change_info.description = 'deescription' |
| 49 change_info.files = files | 49 change_info.files = files |
| 50 change_info.GetFiles = lambda : change_info.files | 50 change_info.GetFiles = lambda : change_info.files |
| 51 change_info.GetIssueDescription = lambda : change_info.description | 51 change_info.GetIssueDescription = lambda : change_info.description |
| 52 change_info.GetFileNames = lambda : [f[1] for f in change_info.files] | 52 change_info.GetFileNames = lambda : [f[1] for f in change_info.files] |
| 53 change_info.GetLocalRoot = lambda : 'proout' | 53 change_info.GetLocalRoot = lambda : 'proout' |
| 54 change_info.patch = None | 54 change_info.patch = None |
| 55 change_info.rietveld = 'https://my_server' | 55 change_info.rietveld = 'https://my_server' |
| 56 change_info.reviewers = None | 56 change_info.reviewers = None |
| 57 change_info._closed = False | 57 change_info._closed = False |
| 58 change_info._deleted = False | 58 change_info._deleted = False |
| 59 change_info._comments_added = [] | 59 change_info._comments_added = [] |
| 60 | 60 |
| 61 class RpcServer(object): |
| 62 def get_issue_properties(self, *_): # pylint: disable=R0201 |
| 63 return { 'patchsets': [1337] } |
| 64 change_info.RpcServer = RpcServer |
| 65 |
| 61 def AddComment(comment): | 66 def AddComment(comment): |
| 62 # pylint: disable=W0212 | 67 # pylint: disable=W0212 |
| 63 change_info._comments_added.append(comment) | 68 change_info._comments_added.append(comment) |
| 64 change_info.AddComment = AddComment | 69 change_info.AddComment = AddComment |
| 65 | 70 |
| 66 def Delete(): | 71 def Delete(): |
| 67 change_info._deleted = True | 72 change_info._deleted = True |
| 68 change_info.Delete = Delete | 73 change_info.Delete = Delete |
| 69 | 74 |
| 70 def CloseIssue(): | 75 def CloseIssue(): |
| (...skipping 517 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 588 | 593 |
| 589 retval = gcl.CMDcommit(['naame']) | 594 retval = gcl.CMDcommit(['naame']) |
| 590 self.assertEquals(retval, 0) | 595 self.assertEquals(retval, 0) |
| 591 self.assertEquals(change_info.description, | 596 self.assertEquals(change_info.description, |
| 592 'deescription\n\nCommitted: http://view/12345') | 597 'deescription\n\nCommitted: http://view/12345') |
| 593 # pylint: disable=W0212 | 598 # pylint: disable=W0212 |
| 594 self.assertTrue(change_info._deleted) | 599 self.assertTrue(change_info._deleted) |
| 595 self.assertTrue(change_info._closed) | 600 self.assertTrue(change_info._closed) |
| 596 self.assertEqual( | 601 self.assertEqual( |
| 597 change_info._comments_added, | 602 change_info._comments_added, |
| 598 ["Committed manually as r12345 (presubmit successful)."]) | 603 ["Committed patchset #1 manually as r12345 (presubmit successful)."]) |
| 599 | 604 |
| 600 | 605 |
| 601 if __name__ == '__main__': | 606 if __name__ == '__main__': |
| 602 import unittest | 607 import unittest |
| 603 unittest.main() | 608 unittest.main() |
| OLD | NEW |