Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(49)

Side by Side Diff: tests/trychange_unittest.py

Issue 503068: Make breakpad, gcl and presubmit_support dependencies optional (Closed)
Patch Set: Fix spurious error Created 11 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « gclient_utils.py ('k') | trychange.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 17 matching lines...) Expand all
28 self.options.files = self.expected_files 28 self.options.files = self.expected_files
29 self.options.diff = None 29 self.options.diff = None
30 self.options.name = None 30 self.options.name = None
31 self.options.email = None 31 self.options.email = None
32 32
33 33
34 class TryChangeUnittest(TryChangeTestsBase): 34 class TryChangeUnittest(TryChangeTestsBase):
35 """General trychange.py tests.""" 35 """General trychange.py tests."""
36 def testMembersChanged(self): 36 def testMembersChanged(self):
37 members = [ 37 members = [
38 'EscapeDot', 'GIT', 'GetTryServerSettings', 'GuessVCS', 38 'EscapeDot', 'GIT', 'GuessVCS',
39 'HELP_STRING', 'InvalidScript', 'NoTryServerAccess', 39 'HELP_STRING', 'InvalidScript', 'NoTryServerAccess',
40 'SCM', 'SVN', 'TryChange', 'USAGE', 'breakpad', 40 'SCM', 'SVN', 'TryChange', 'USAGE',
41 'datetime', 'gcl', 'gclient_utils', 'getpass', 'logging', 41 'breakpad', 'datetime', 'gclient_utils', 'getpass', 'logging',
42 'optparse', 'os', 'presubmit_support', 'scm', 'shutil', 'socket', 42 'optparse', 'os', 'scm', 'shutil', 'socket',
43 'subprocess', 'sys', 'tempfile', 'urllib', 43 'subprocess', 'sys', 'tempfile', 'urllib',
44 ] 44 ]
45 # If this test fails, you should add the relevant test. 45 # If this test fails, you should add the relevant test.
46 self.compareMembers(trychange, members) 46 self.compareMembers(trychange, members)
47 47
48 48
49 class SVNUnittest(TryChangeTestsBase): 49 class SVNUnittest(TryChangeTestsBase):
50 """trychange.SVN tests.""" 50 """trychange.SVN tests."""
51 def testMembersChanged(self): 51 def testMembersChanged(self):
52 members = [ 52 members = [
53 'GetFileNames', 'GetLocalRoot', 53 'GetBots', 'GetFileNames', 'GetLocalRoot',
54 ] 54 ]
55 # If this test fails, you should add the relevant test. 55 # If this test fails, you should add the relevant test.
56 self.compareMembers(trychange.SVN, members) 56 self.compareMembers(trychange.SVN, members)
57 57
58 def testBasic(self): 58 def testBasic(self):
59 trychange.os.getcwd().AndReturn(self.fake_root) 59 trychange.os.getcwd().AndReturn(self.fake_root)
60 trychange.scm.SVN.GetCheckoutRoot(self.fake_root).AndReturn(self.fake_root) 60 trychange.scm.SVN.GetCheckoutRoot(self.fake_root).AndReturn(self.fake_root)
61 trychange.os.getcwd().AndReturn('pro') 61 trychange.os.getcwd().AndReturn('pro')
62 trychange.os.chdir(self.fake_root) 62 trychange.os.chdir(self.fake_root)
63 trychange.scm.SVN.DiffItem(self.expected_files[0]).AndReturn('bleh') 63 trychange.scm.SVN.DiffItem(self.expected_files[0]).AndReturn('bleh')
64 trychange.scm.SVN.DiffItem(self.expected_files[1]).AndReturn('blew') 64 trychange.scm.SVN.DiffItem(self.expected_files[1]).AndReturn('blew')
65 trychange.os.chdir('pro') 65 trychange.os.chdir('pro')
66 trychange.scm.SVN.GetEmail(self.fake_root).AndReturn('georges@example.com') 66 trychange.scm.SVN.GetEmail(self.fake_root).AndReturn('georges@example.com')
67 self.mox.ReplayAll() 67 self.mox.ReplayAll()
68 svn = trychange.SVN(self.options) 68 svn = trychange.SVN(self.options)
69 self.assertEqual(svn.GetFileNames(), self.expected_files) 69 self.assertEqual(svn.GetFileNames(), self.expected_files)
70 self.assertEqual(svn.GetLocalRoot(), self.fake_root) 70 self.assertEqual(svn.GetLocalRoot(), self.fake_root)
71 71
72 72
73 class GITUnittest(TryChangeTestsBase): 73 class GITUnittest(TryChangeTestsBase):
74 """trychange.GIT tests.""" 74 """trychange.GIT tests."""
75 def testMembersChanged(self): 75 def testMembersChanged(self):
76 members = [ 76 members = [
77 'GetFileNames', 'GetLocalRoot', 77 'GetBots', 'GetFileNames', 'GetLocalRoot',
78 ] 78 ]
79 # If this test fails, you should add the relevant test. 79 # If this test fails, you should add the relevant test.
80 self.compareMembers(trychange.GIT, members) 80 self.compareMembers(trychange.GIT, members)
81 81
82 def testBasic(self): 82 def testBasic(self):
83 trychange.gclient_utils.CheckCall( 83 trychange.gclient_utils.CheckCall(
84 ['git', 'rev-parse', '--show-cdup']).AndReturn(self.fake_root) 84 ['git', 'rev-parse', '--show-cdup']).AndReturn(self.fake_root)
85 trychange.os.path.abspath(self.fake_root).AndReturn(self.fake_root) 85 trychange.os.path.abspath(self.fake_root).AndReturn(self.fake_root)
86 trychange.gclient_utils.CheckCall( 86 trychange.gclient_utils.CheckCall(
87 ['git', 'cl', 'upstream']).AndReturn('random branch') 87 ['git', 'cl', 'upstream']).AndReturn('random branch')
88 trychange.gclient_utils.CheckCall( 88 trychange.gclient_utils.CheckCall(
89 ['git', 'diff-tree', '-p', '--no-prefix', 'random branch', 'HEAD'] 89 ['git', 'diff-tree', '-p', '--no-prefix', 'random branch', 'HEAD']
90 ).AndReturn('This is a dummy diff\n+3\n-4\n') 90 ).AndReturn('This is a dummy diff\n+3\n-4\n')
91 trychange.gclient_utils.CheckCall( 91 trychange.gclient_utils.CheckCall(
92 ['git', 'symbolic-ref', 'HEAD']).AndReturn('refs/heads/another branch') 92 ['git', 'symbolic-ref', 'HEAD']).AndReturn('refs/heads/another branch')
93 trychange.scm.GIT.GetEmail('.').AndReturn('georges@example.com') 93 trychange.scm.GIT.GetEmail('.').AndReturn('georges@example.com')
94 self.mox.ReplayAll() 94 self.mox.ReplayAll()
95 git = trychange.GIT(self.options) 95 git = trychange.GIT(self.options)
96 self.assertEqual(git.GetFileNames(), self.expected_files) 96 self.assertEqual(git.GetFileNames(), self.expected_files)
97 self.assertEqual(git.GetLocalRoot(), self.fake_root) 97 self.assertEqual(git.GetLocalRoot(), self.fake_root)
98 98
99 99
100 if __name__ == '__main__': 100 if __name__ == '__main__':
101 import unittest 101 import unittest
102 unittest.main() 102 unittest.main()
OLDNEW
« no previous file with comments | « gclient_utils.py ('k') | trychange.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698