OLD | NEW |
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 # Copyright (c) 2011 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2011 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 # pylint: disable=E1103,W0403 | 8 import os |
| 9 import sys |
9 | 10 |
10 # Fixes include path. | 11 sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) |
| 12 |
11 from super_mox import SuperMoxTestBase | 13 from super_mox import SuperMoxTestBase |
12 | 14 |
13 import subprocess2 | 15 import subprocess2 |
14 import trychange | 16 import trychange |
15 | 17 |
16 | 18 |
17 class TryChangeTestsBase(SuperMoxTestBase): | 19 class TryChangeTestsBase(SuperMoxTestBase): |
18 """Setups and tear downs the mocks but doesn't test anything as-is.""" | 20 """Setups and tear downs the mocks but doesn't test anything as-is.""" |
19 def setUp(self): | 21 def setUp(self): |
20 SuperMoxTestBase.setUp(self) | 22 SuperMoxTestBase.setUp(self) |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
84 """trychange.GIT tests.""" | 86 """trychange.GIT tests.""" |
85 def testMembersChanged(self): | 87 def testMembersChanged(self): |
86 members = [ | 88 members = [ |
87 'AutomagicalSettings', 'CaptureStatus', 'GetCodeReviewSetting', | 89 'AutomagicalSettings', 'CaptureStatus', 'GetCodeReviewSetting', |
88 'ReadRootFile', 'GenerateDiff', 'GetFileNames', 'files', 'file_tuples', | 90 'ReadRootFile', 'GenerateDiff', 'GetFileNames', 'files', 'file_tuples', |
89 ] | 91 ] |
90 # If this test fails, you should add the relevant test. | 92 # If this test fails, you should add the relevant test. |
91 self.compareMembers(trychange.GIT, members) | 93 self.compareMembers(trychange.GIT, members) |
92 | 94 |
93 def testBasic(self): | 95 def testBasic(self): |
| 96 # pylint: disable=E1103 |
94 trychange.os.path.abspath(self.fake_root).AndReturn(self.fake_root) | 97 trychange.os.path.abspath(self.fake_root).AndReturn(self.fake_root) |
95 trychange.scm.GIT.GetCheckoutRoot(self.fake_root).AndReturn(self.fake_root) | 98 trychange.scm.GIT.GetCheckoutRoot(self.fake_root).AndReturn(self.fake_root) |
96 trychange.scm.GIT.GetUpstreamBranch(self.fake_root).AndReturn('somewhere') | 99 trychange.scm.GIT.GetUpstreamBranch(self.fake_root).AndReturn('somewhere') |
97 trychange.scm.GIT.GenerateDiff(self.fake_root, | 100 trychange.scm.GIT.GenerateDiff(self.fake_root, |
98 full_move=True, | 101 full_move=True, |
99 files=['foo.txt', 'bar.txt'], | 102 files=['foo.txt', 'bar.txt'], |
100 branch='somewhere').AndReturn('A diff') | 103 branch='somewhere').AndReturn('A diff') |
101 trychange.scm.GIT.GetPatchName(self.fake_root).AndReturn('bleh-1233') | 104 trychange.scm.GIT.GetPatchName(self.fake_root).AndReturn('bleh-1233') |
102 trychange.scm.GIT.GetEmail(self.fake_root).AndReturn('georges@example.com') | 105 trychange.scm.GIT.GetEmail(self.fake_root).AndReturn('georges@example.com') |
103 self.mox.ReplayAll() | 106 self.mox.ReplayAll() |
104 git = trychange.GIT(self.options, self.fake_root, self.options.files) | 107 git = trychange.GIT(self.options, self.fake_root, self.options.files) |
105 self.assertEqual(git.GetFileNames(), self.expected_files) | 108 self.assertEqual(git.GetFileNames(), self.expected_files) |
106 self.assertEqual(git.checkout_root, self.fake_root) | 109 self.assertEqual(git.checkout_root, self.fake_root) |
107 self.assertEqual(git.GenerateDiff(), 'A diff') | 110 self.assertEqual(git.GenerateDiff(), 'A diff') |
108 | 111 |
109 | 112 |
110 if __name__ == '__main__': | 113 if __name__ == '__main__': |
111 import unittest | 114 import unittest |
112 unittest.main() | 115 unittest.main() |
OLD | NEW |