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