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

Side by Side Diff: tests/trychange_unittest.py

Issue 524046: Add "diff against" support when sending try patches. (Closed)
Patch Set: Created 10 years, 11 months 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
« scm.py ('K') | « scm.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 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
56 members = [ 56 members = [
57 'AutomagicalSettings', 'GclStyleSettings', 'GclientStyleSettings', 57 'AutomagicalSettings', 'GclStyleSettings', 'GclientStyleSettings',
58 'GetCodeReviewSetting', 'ReadRootFile', 58 'GetCodeReviewSetting', 'ReadRootFile',
59 'GenerateDiff', 'GetFileNames', 'GetLocalRoot', 59 'GenerateDiff', 'GetFileNames', 'GetLocalRoot',
60 ] 60 ]
61 # If this test fails, you should add the relevant test. 61 # If this test fails, you should add the relevant test.
62 self.compareMembers(trychange.SVN, members) 62 self.compareMembers(trychange.SVN, members)
63 63
64 def testBasic(self): 64 def testBasic(self):
65 trychange.scm.SVN.GetCheckoutRoot(self.fake_root).AndReturn(self.fake_root) 65 trychange.scm.SVN.GetCheckoutRoot(self.fake_root).AndReturn(self.fake_root)
66 trychange.scm.SVN.GenerateDiff(['foo.txt', 'bar.txt'], self.fake_root, 66 trychange.scm.SVN.GenerateDiff(['foo.txt', 'bar.txt'],
67 full_move=True).AndReturn('A diff') 67 self.fake_root,
68 full_move=True,
69 revision=None).AndReturn('A diff')
68 trychange.scm.SVN.GetEmail(self.fake_root).AndReturn('georges@example.com') 70 trychange.scm.SVN.GetEmail(self.fake_root).AndReturn('georges@example.com')
69 self.mox.ReplayAll() 71 self.mox.ReplayAll()
70 svn = trychange.SVN(self.options, self.fake_root) 72 svn = trychange.SVN(self.options, self.fake_root)
71 self.assertEqual(svn.GetFileNames(), self.expected_files) 73 self.assertEqual(svn.GetFileNames(), self.expected_files)
72 self.assertEqual(svn.GetLocalRoot(), self.fake_root) 74 self.assertEqual(svn.GetLocalRoot(), self.fake_root)
73 self.assertEqual(svn.GenerateDiff(), 'A diff') 75 self.assertEqual(svn.GenerateDiff(), 'A diff')
74 76
75 77
76 class GITUnittest(TryChangeTestsBase): 78 class GITUnittest(TryChangeTestsBase):
77 """trychange.GIT tests.""" 79 """trychange.GIT tests."""
78 def testMembersChanged(self): 80 def testMembersChanged(self):
79 members = [ 81 members = [
80 'AutomagicalSettings', 'GclStyleSettings', 'GclientStyleSettings', 82 'AutomagicalSettings', 'GclStyleSettings', 'GclientStyleSettings',
81 'GetCodeReviewSetting', 'ReadRootFile', 83 'GetCodeReviewSetting', 'ReadRootFile',
82 'GenerateDiff', 'GetFileNames', 'GetLocalRoot', 84 'GenerateDiff', 'GetFileNames', 'GetLocalRoot',
83 ] 85 ]
84 # If this test fails, you should add the relevant test. 86 # If this test fails, you should add the relevant test.
85 self.compareMembers(trychange.GIT, members) 87 self.compareMembers(trychange.GIT, members)
86 88
87 def testBasic(self): 89 def testBasic(self):
88 trychange.scm.GIT.GetCheckoutRoot(self.fake_root).AndReturn(self.fake_root) 90 trychange.scm.GIT.GetCheckoutRoot(self.fake_root).AndReturn(self.fake_root)
89 trychange.scm.GIT.GenerateDiff(self.fake_root, 91 trychange.scm.GIT.GenerateDiff(self.fake_root,
90 full_move=True).AndReturn('A diff') 92 full_move=True,
93 branch=None).AndReturn('A diff')
91 trychange.scm.GIT.GetPatchName(self.fake_root).AndReturn('bleh-1233') 94 trychange.scm.GIT.GetPatchName(self.fake_root).AndReturn('bleh-1233')
92 trychange.scm.GIT.GetEmail(self.fake_root).AndReturn('georges@example.com') 95 trychange.scm.GIT.GetEmail(self.fake_root).AndReturn('georges@example.com')
93 self.mox.ReplayAll() 96 self.mox.ReplayAll()
94 git = trychange.GIT(self.options, self.fake_root) 97 git = trychange.GIT(self.options, self.fake_root)
95 self.assertEqual(git.GetFileNames(), self.expected_files) 98 self.assertEqual(git.GetFileNames(), self.expected_files)
96 self.assertEqual(git.GetLocalRoot(), self.fake_root) 99 self.assertEqual(git.GetLocalRoot(), self.fake_root)
97 self.assertEqual(git.GenerateDiff(), 'A diff') 100 self.assertEqual(git.GenerateDiff(), 'A diff')
98 101
99 102
100 if __name__ == '__main__': 103 if __name__ == '__main__':
101 import unittest 104 import unittest
102 unittest.main() 105 unittest.main()
OLDNEW
« scm.py ('K') | « scm.py ('k') | trychange.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698