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 trychange.py.""" | 6 """Unit tests for trychange.py.""" |
7 | 7 |
8 import os | 8 import os |
9 import sys | 9 import sys |
10 import unittest | 10 import unittest |
(...skipping 11 matching lines...) Expand all Loading... |
22 def setUp(self): | 22 def setUp(self): |
23 SuperMoxTestBase.setUp(self) | 23 SuperMoxTestBase.setUp(self) |
24 self.mox.StubOutWithMock(subprocess2, 'communicate') | 24 self.mox.StubOutWithMock(subprocess2, 'communicate') |
25 self.mox.StubOutWithMock(trychange, 'RunGit') | 25 self.mox.StubOutWithMock(trychange, 'RunGit') |
26 self.mox.StubOutWithMock(trychange.scm.GIT, 'Capture') | 26 self.mox.StubOutWithMock(trychange.scm.GIT, 'Capture') |
27 self.mox.StubOutWithMock(trychange.scm.GIT, 'GenerateDiff') | 27 self.mox.StubOutWithMock(trychange.scm.GIT, 'GenerateDiff') |
28 self.mox.StubOutWithMock(trychange.scm.GIT, 'GetCheckoutRoot') | 28 self.mox.StubOutWithMock(trychange.scm.GIT, 'GetCheckoutRoot') |
29 self.mox.StubOutWithMock(trychange.scm.GIT, 'GetEmail') | 29 self.mox.StubOutWithMock(trychange.scm.GIT, 'GetEmail') |
30 self.mox.StubOutWithMock(trychange.scm.GIT, 'GetPatchName') | 30 self.mox.StubOutWithMock(trychange.scm.GIT, 'GetPatchName') |
31 self.mox.StubOutWithMock(trychange.scm.GIT, 'GetUpstreamBranch') | 31 self.mox.StubOutWithMock(trychange.scm.GIT, 'GetUpstreamBranch') |
32 self.mox.StubOutWithMock(trychange.scm.SVN, 'DiffItem') | |
33 self.mox.StubOutWithMock(trychange.scm.SVN, 'GenerateDiff') | 32 self.mox.StubOutWithMock(trychange.scm.SVN, 'GenerateDiff') |
34 self.mox.StubOutWithMock(trychange.scm.SVN, 'GetCheckoutRoot') | 33 self.mox.StubOutWithMock(trychange.scm.SVN, 'GetCheckoutRoot') |
35 self.mox.StubOutWithMock(trychange.scm.SVN, 'GetEmail') | 34 self.mox.StubOutWithMock(trychange.scm.SVN, 'GetEmail') |
36 self.fake_root = self.Dir() | 35 self.fake_root = self.Dir() |
37 self.expected_files = ['foo.txt', 'bar.txt'] | 36 self.expected_files = ['foo.txt', 'bar.txt'] |
38 self.options = trychange.optparse.Values() | 37 self.options = trychange.optparse.Values() |
39 self.options.files = self.expected_files | 38 self.options.files = self.expected_files |
40 self.options.diff = None | 39 self.options.diff = None |
41 self.options.name = None | 40 self.options.name = None |
42 self.options.email = None | 41 self.options.email = None |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
146 trychange.scm.GIT.GetEmail(self.fake_root).AndReturn('georges@example.com') | 145 trychange.scm.GIT.GetEmail(self.fake_root).AndReturn('georges@example.com') |
147 self.mox.ReplayAll() | 146 self.mox.ReplayAll() |
148 git = trychange.GIT(self.options, self.fake_root, self.options.files) | 147 git = trychange.GIT(self.options, self.fake_root, self.options.files) |
149 self.assertEqual(git.GetFileNames(), self.expected_files) | 148 self.assertEqual(git.GetFileNames(), self.expected_files) |
150 self.assertEqual(git.checkout_root, self.fake_root) | 149 self.assertEqual(git.checkout_root, self.fake_root) |
151 self.assertEqual(git.GenerateDiff(), 'A diff') | 150 self.assertEqual(git.GenerateDiff(), 'A diff') |
152 | 151 |
153 | 152 |
154 if __name__ == '__main__': | 153 if __name__ == '__main__': |
155 unittest.main() | 154 unittest.main() |
OLD | NEW |