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 |
11 import trychange | 11 import trychange |
12 from super_mox import mox, SuperMoxTestBase | 12 from super_mox import mox, SuperMoxTestBase |
13 | 13 |
14 | 14 |
15 class TryChangeTestsBase(SuperMoxTestBase): | 15 class TryChangeTestsBase(SuperMoxTestBase): |
16 """Setups and tear downs the mocks but doesn't test anything as-is.""" | 16 """Setups and tear downs the mocks but doesn't test anything as-is.""" |
17 pass | 17 pass |
18 | 18 |
19 | 19 |
20 class TryChangeUnittest(TryChangeTestsBase): | 20 class TryChangeUnittest(TryChangeTestsBase): |
21 """General trychange.py tests.""" | 21 """General trychange.py tests.""" |
22 def testMembersChanged(self): | 22 def testMembersChanged(self): |
23 members = [ | 23 members = [ |
24 'EscapeDot', 'GIT', 'GetSourceRoot', | 24 'EscapeDot', 'GIT', 'GetSourceRoot', |
25 'GetTryServerSettings', 'GuessVCS', | 25 'GetTryServerSettings', 'GuessVCS', |
26 'HELP_STRING', 'InvalidScript', 'NoTryServerAccess', 'PathDifference', | 26 'HELP_STRING', 'InvalidScript', 'NoTryServerAccess', 'PathDifference', |
27 'RunCommand', 'SCM', 'SVN', 'TryChange', 'USAGE', | 27 'RunCommand', 'SCM', 'SVN', 'TryChange', 'USAGE', |
28 'datetime', 'gcl', 'gclient_scm', 'getpass', 'logging', | 28 'datetime', 'gcl', 'getpass', 'logging', |
29 'optparse', 'os', 'presubmit_support', 'shutil', 'socket', 'subprocess', | 29 'optparse', 'os', 'presubmit_support', 'scm', 'shutil', 'socket', |
30 'sys', 'tempfile', 'upload', 'urllib', | 30 'subprocess', 'sys', 'tempfile', 'upload', 'urllib', |
31 ] | 31 ] |
32 # If this test fails, you should add the relevant test. | 32 # If this test fails, you should add the relevant test. |
33 self.compareMembers(trychange, members) | 33 self.compareMembers(trychange, members) |
34 | 34 |
35 | 35 |
36 class SVNUnittest(TryChangeTestsBase): | 36 class SVNUnittest(TryChangeTestsBase): |
37 """trychange.SVN tests.""" | 37 """trychange.SVN tests.""" |
38 def setUp(self): | 38 def setUp(self): |
39 SuperMoxTestBase.setUp(self) | 39 SuperMoxTestBase.setUp(self) |
40 self.fake_root = '/fake_root' | 40 self.fake_root = '/fake_root' |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 |