| 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 'GetBots', 'GetFileNames', 'GetLocalRoot', | 57 'GenerateDiff', 'GetBots', 'GetFileNames', 'GetLocalRoot', |
| 58 ] | 58 ] |
| 59 # If this test fails, you should add the relevant test. | 59 # If this test fails, you should add the relevant test. |
| 60 self.compareMembers(trychange.SVN, members) | 60 self.compareMembers(trychange.SVN, members) |
| 61 | 61 |
| 62 def testBasic(self): | 62 def testBasic(self): |
| 63 trychange.os.getcwd().AndReturn(self.fake_root) | |
| 64 trychange.scm.SVN.GetCheckoutRoot(self.fake_root).AndReturn(self.fake_root) | 63 trychange.scm.SVN.GetCheckoutRoot(self.fake_root).AndReturn(self.fake_root) |
| 65 trychange.scm.SVN.GenerateDiff(['foo.txt', 'bar.txt'], | 64 trychange.scm.SVN.GenerateDiff(['foo.txt', 'bar.txt'], self.fake_root, |
| 66 full_move=True).AndReturn('A diff') | 65 full_move=True).AndReturn('A diff') |
| 67 trychange.scm.SVN.GetEmail(self.fake_root).AndReturn('georges@example.com') | 66 trychange.scm.SVN.GetEmail(self.fake_root).AndReturn('georges@example.com') |
| 68 self.mox.ReplayAll() | 67 self.mox.ReplayAll() |
| 69 svn = trychange.SVN(self.options) | 68 svn = trychange.SVN(self.options, self.fake_root) |
| 70 self.assertEqual(svn.GetFileNames(), self.expected_files) | 69 self.assertEqual(svn.GetFileNames(), self.expected_files) |
| 71 self.assertEqual(svn.GetLocalRoot(), self.fake_root) | 70 self.assertEqual(svn.GetLocalRoot(), self.fake_root) |
| 71 self.assertEqual(svn.GenerateDiff(), 'A diff') |
| 72 | 72 |
| 73 | 73 |
| 74 class GITUnittest(TryChangeTestsBase): | 74 class GITUnittest(TryChangeTestsBase): |
| 75 """trychange.GIT tests.""" | 75 """trychange.GIT tests.""" |
| 76 def testMembersChanged(self): | 76 def testMembersChanged(self): |
| 77 members = [ | 77 members = [ |
| 78 'GetBots', 'GetFileNames', 'GetLocalRoot', | 78 'GenerateDiff', 'GetBots', 'GetFileNames', 'GetLocalRoot', |
| 79 ] | 79 ] |
| 80 # If this test fails, you should add the relevant test. | 80 # If this test fails, you should add the relevant test. |
| 81 self.compareMembers(trychange.GIT, members) | 81 self.compareMembers(trychange.GIT, members) |
| 82 | 82 |
| 83 def testBasic(self): | 83 def testBasic(self): |
| 84 trychange.os.getcwd().AndReturn(self.fake_root) | |
| 85 trychange.scm.GIT.GetCheckoutRoot(self.fake_root).AndReturn(self.fake_root) | 84 trychange.scm.GIT.GetCheckoutRoot(self.fake_root).AndReturn(self.fake_root) |
| 86 trychange.scm.GIT.GenerateDiff(self.fake_root, | 85 trychange.scm.GIT.GenerateDiff(self.fake_root, |
| 87 full_move=True).AndReturn('a diff') | 86 full_move=True).AndReturn('A diff') |
| 88 trychange.scm.GIT.GetPatchName(self.fake_root).AndReturn('bleh-1233') | 87 trychange.scm.GIT.GetPatchName(self.fake_root).AndReturn('bleh-1233') |
| 89 trychange.scm.GIT.GetEmail(self.fake_root).AndReturn('georges@example.com') | 88 trychange.scm.GIT.GetEmail(self.fake_root).AndReturn('georges@example.com') |
| 90 self.mox.ReplayAll() | 89 self.mox.ReplayAll() |
| 91 git = trychange.GIT(self.options) | 90 git = trychange.GIT(self.options, self.fake_root) |
| 92 self.assertEqual(git.GetFileNames(), self.expected_files) | 91 self.assertEqual(git.GetFileNames(), self.expected_files) |
| 93 self.assertEqual(git.GetLocalRoot(), self.fake_root) | 92 self.assertEqual(git.GetLocalRoot(), self.fake_root) |
| 93 self.assertEqual(git.GenerateDiff(), 'A diff') |
| 94 | 94 |
| 95 | 95 |
| 96 if __name__ == '__main__': | 96 if __name__ == '__main__': |
| 97 import unittest | 97 import unittest |
| 98 unittest.main() | 98 unittest.main() |
| OLD | NEW |