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 import unittest | 9 import unittest |
10 | 10 |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
62 self.assertEqual(self.svn.GetFileNames(), self.expected_files) | 62 self.assertEqual(self.svn.GetFileNames(), self.expected_files) |
63 | 63 |
64 def testGetLocalRoot(self): | 64 def testGetLocalRoot(self): |
65 self.mox.ReplayAll() | 65 self.mox.ReplayAll() |
66 self.assertEqual(self.svn.GetLocalRoot(), self.fake_root) | 66 self.assertEqual(self.svn.GetLocalRoot(), self.fake_root) |
67 | 67 |
68 | 68 |
69 class GITUnittest(TryChangeTestsBase): | 69 class GITUnittest(TryChangeTestsBase): |
70 """trychange.GIT tests.""" | 70 """trychange.GIT tests.""" |
71 def setUp(self): | 71 def setUp(self): |
72 self.fake_root = '/fake_root' | 72 self.fake_root = gcl.os.path.join(gcl.os.path.dirname(__file__), |
| 73 'fake_root') |
73 self.expected_files = ['foo.txt', 'bar.txt'] | 74 self.expected_files = ['foo.txt', 'bar.txt'] |
74 options = optparse.Values() | 75 options = optparse.Values() |
75 options.files = self.expected_files | 76 options.files = self.expected_files |
76 self.git = trychange.GIT(options) | 77 self.git = trychange.GIT(options) |
77 super_mox.SuperMoxTestBase.setUp(self) | 78 super_mox.SuperMoxTestBase.setUp(self) |
78 | 79 |
79 def testMembersChanged(self): | 80 def testMembersChanged(self): |
80 members = [ | 81 members = [ |
81 'GenerateDiff', 'GetEmail', 'GetFileNames', 'GetLocalRoot', | 82 'GenerateDiff', 'GetEmail', 'GetFileNames', 'GetLocalRoot', |
82 'GetPatchName', 'ProcessOptions', 'options' | 83 'GetPatchName', 'ProcessOptions', 'options' |
83 ] | 84 ] |
84 # If this test fails, you should add the relevant test. | 85 # If this test fails, you should add the relevant test. |
85 self.compareMembers(trychange.GIT(None), members) | 86 self.compareMembers(trychange.GIT(None), members) |
86 | 87 |
87 def testGetFileNames(self): | 88 def testGetFileNames(self): |
88 self.mox.ReplayAll() | 89 self.mox.ReplayAll() |
89 self.assertEqual(self.git.GetFileNames(), self.expected_files) | 90 self.assertEqual(self.git.GetFileNames(), self.expected_files) |
90 | 91 |
91 def testGetLocalRoot(self): | 92 def testGetLocalRoot(self): |
92 self.mox.StubOutWithMock(upload, 'RunShell') | 93 self.mox.StubOutWithMock(upload, 'RunShell') |
93 upload.RunShell(['git', 'rev-parse', '--show-cdup']).AndReturn( | 94 upload.RunShell(['git', 'rev-parse', '--show-cdup']).AndReturn( |
94 self.fake_root) | 95 self.fake_root) |
95 self.mox.ReplayAll() | 96 self.mox.ReplayAll() |
96 self.assertEqual(self.git.GetLocalRoot(), self.fake_root) | 97 self.assertEqual(self.git.GetLocalRoot(), self.fake_root) |
97 | 98 |
98 | 99 |
99 if __name__ == '__main__': | 100 if __name__ == '__main__': |
100 unittest.main() | 101 unittest.main() |
OLD | NEW |