| 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 trychange.py.""" | 6 """Unit tests for trychange.py.""" |
| 7 | 7 |
| 8 import optparse | 8 import optparse |
| 9 | 9 |
| 10 # Local imports | 10 # Local imports |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 47 'subprocess', 'sys', 'tempfile', 'urllib', | 47 'subprocess', 'sys', 'tempfile', 'urllib', |
| 48 ] | 48 ] |
| 49 # If this test fails, you should add the relevant test. | 49 # If this test fails, you should add the relevant test. |
| 50 self.compareMembers(trychange, members) | 50 self.compareMembers(trychange, members) |
| 51 | 51 |
| 52 | 52 |
| 53 class SVNUnittest(TryChangeTestsBase): | 53 class SVNUnittest(TryChangeTestsBase): |
| 54 """trychange.SVN tests.""" | 54 """trychange.SVN tests.""" |
| 55 def testMembersChanged(self): | 55 def testMembersChanged(self): |
| 56 members = [ | 56 members = [ |
| 57 'GenerateDiff', 'GetBots', 'GetFileNames', 'GetLocalRoot', | 57 'AutomagicalSettings', 'GclStyleSettings', 'GclientStyleSettings', |
| 58 'GetCodeReviewSetting', 'ReadRootFile', |
| 59 'GenerateDiff', 'GetFileNames', 'GetLocalRoot', |
| 58 ] | 60 ] |
| 59 # If this test fails, you should add the relevant test. | 61 # If this test fails, you should add the relevant test. |
| 60 self.compareMembers(trychange.SVN, members) | 62 self.compareMembers(trychange.SVN, members) |
| 61 | 63 |
| 62 def testBasic(self): | 64 def testBasic(self): |
| 63 trychange.scm.SVN.GetCheckoutRoot(self.fake_root).AndReturn(self.fake_root) | 65 trychange.scm.SVN.GetCheckoutRoot(self.fake_root).AndReturn(self.fake_root) |
| 64 trychange.scm.SVN.GenerateDiff(['foo.txt', 'bar.txt'], self.fake_root, | 66 trychange.scm.SVN.GenerateDiff(['foo.txt', 'bar.txt'], self.fake_root, |
| 65 full_move=True).AndReturn('A diff') | 67 full_move=True).AndReturn('A diff') |
| 66 trychange.scm.SVN.GetEmail(self.fake_root).AndReturn('georges@example.com') | 68 trychange.scm.SVN.GetEmail(self.fake_root).AndReturn('georges@example.com') |
| 67 self.mox.ReplayAll() | 69 self.mox.ReplayAll() |
| 68 svn = trychange.SVN(self.options, self.fake_root) | 70 svn = trychange.SVN(self.options, self.fake_root) |
| 69 self.assertEqual(svn.GetFileNames(), self.expected_files) | 71 self.assertEqual(svn.GetFileNames(), self.expected_files) |
| 70 self.assertEqual(svn.GetLocalRoot(), self.fake_root) | 72 self.assertEqual(svn.GetLocalRoot(), self.fake_root) |
| 71 self.assertEqual(svn.GenerateDiff(), 'A diff') | 73 self.assertEqual(svn.GenerateDiff(), 'A diff') |
| 72 | 74 |
| 73 | 75 |
| 74 class GITUnittest(TryChangeTestsBase): | 76 class GITUnittest(TryChangeTestsBase): |
| 75 """trychange.GIT tests.""" | 77 """trychange.GIT tests.""" |
| 76 def testMembersChanged(self): | 78 def testMembersChanged(self): |
| 77 members = [ | 79 members = [ |
| 78 'GenerateDiff', 'GetBots', 'GetFileNames', 'GetLocalRoot', | 80 'AutomagicalSettings', 'GclStyleSettings', 'GclientStyleSettings', |
| 81 'GetCodeReviewSetting', 'ReadRootFile', |
| 82 'GenerateDiff', 'GetFileNames', 'GetLocalRoot', |
| 79 ] | 83 ] |
| 80 # If this test fails, you should add the relevant test. | 84 # If this test fails, you should add the relevant test. |
| 81 self.compareMembers(trychange.GIT, members) | 85 self.compareMembers(trychange.GIT, members) |
| 82 | 86 |
| 83 def testBasic(self): | 87 def testBasic(self): |
| 84 trychange.scm.GIT.GetCheckoutRoot(self.fake_root).AndReturn(self.fake_root) | 88 trychange.scm.GIT.GetCheckoutRoot(self.fake_root).AndReturn(self.fake_root) |
| 85 trychange.scm.GIT.GenerateDiff(self.fake_root, | 89 trychange.scm.GIT.GenerateDiff(self.fake_root, |
| 86 full_move=True).AndReturn('A diff') | 90 full_move=True).AndReturn('A diff') |
| 87 trychange.scm.GIT.GetPatchName(self.fake_root).AndReturn('bleh-1233') | 91 trychange.scm.GIT.GetPatchName(self.fake_root).AndReturn('bleh-1233') |
| 88 trychange.scm.GIT.GetEmail(self.fake_root).AndReturn('georges@example.com') | 92 trychange.scm.GIT.GetEmail(self.fake_root).AndReturn('georges@example.com') |
| 89 self.mox.ReplayAll() | 93 self.mox.ReplayAll() |
| 90 git = trychange.GIT(self.options, self.fake_root) | 94 git = trychange.GIT(self.options, self.fake_root) |
| 91 self.assertEqual(git.GetFileNames(), self.expected_files) | 95 self.assertEqual(git.GetFileNames(), self.expected_files) |
| 92 self.assertEqual(git.GetLocalRoot(), self.fake_root) | 96 self.assertEqual(git.GetLocalRoot(), self.fake_root) |
| 93 self.assertEqual(git.GenerateDiff(), 'A diff') | 97 self.assertEqual(git.GenerateDiff(), 'A diff') |
| 94 | 98 |
| 95 | 99 |
| 96 if __name__ == '__main__': | 100 if __name__ == '__main__': |
| 97 import unittest | 101 import unittest |
| 98 unittest.main() | 102 unittest.main() |
| OLD | NEW |