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 revert.py.""" | 6 """Unit tests for revert.py.""" |
7 | 7 |
8 import revert | 8 import revert |
9 from super_mox import mox, SuperMoxTestBase | 9 from super_mox import mox, SuperMoxTestBase |
10 | 10 |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
54 self.mox.ReplayAll() | 54 self.mox.ReplayAll() |
55 | 55 |
56 self.assertEquals(revert.Main(['revert', '-c', '-f', '-n', '-m', 'bleh', | 56 self.assertEquals(revert.Main(['revert', '-c', '-f', '-n', '-m', 'bleh', |
57 '-r', 'foo@example.com', '42', '23']), | 57 '-r', 'foo@example.com', '42', '23']), |
58 31337) | 58 31337) |
59 | 59 |
60 | 60 |
61 class RevertRevertUnittest(RevertTestsBase): | 61 class RevertRevertUnittest(RevertTestsBase): |
62 def setUp(self): | 62 def setUp(self): |
63 RevertTestsBase.setUp(self) | 63 RevertTestsBase.setUp(self) |
64 self.mox.StubOutWithMock(revert.gclient_scm.scm.SVN, 'CaptureStatus') | |
65 | 64 |
66 def testRevert(self): | 65 def testRevert(self): |
67 revert.gcl.GetRepositoryRoot().AndReturn('foo') | 66 revert.gcl.GetRepositoryRoot().AndReturn('foo') |
68 revert.os.chdir('foo') | 67 revert.os.chdir('foo') |
69 entries = [{ | 68 entries = [{ |
70 'author': 'Georges', | 69 'author': 'Georges', |
71 'paths': [ | 70 'paths': [ |
72 {'path': 'proto://fqdn/repo/random_file'} | 71 {'path': 'proto://fqdn/repo/random_file'} |
73 ], | 72 ], |
74 }] | 73 }] |
75 revert.CaptureSVNLog(['-r', '42', '-v']).AndReturn(entries) | 74 revert.CaptureSVNLog(['-r', '42', '-v']).AndReturn(entries) |
76 revert.GetRepoBase().AndReturn('proto://fqdn/repo/') | 75 revert.GetRepoBase().AndReturn('proto://fqdn/repo/') |
77 revert.gclient_scm.scm.SVN.CaptureStatus(['random_file']).AndReturn([]) | 76 revert.gclient_scm.CaptureSVNStatus(['random_file']).AndReturn([]) |
78 revert.gcl.RunShell(['svn', 'up', 'random_file']) | 77 revert.gcl.RunShell(['svn', 'up', 'random_file']) |
79 revert.os.path.isdir('random_file').AndReturn(False) | 78 revert.os.path.isdir('random_file').AndReturn(False) |
80 status = """--- Reverse-merging r42 into '.': | 79 status = """--- Reverse-merging r42 into '.': |
81 M random_file | 80 M random_file |
82 """ | 81 """ |
83 revert.gcl.RunShellWithReturnCode(['svn', 'merge', '-c', '-42', | 82 revert.gcl.RunShellWithReturnCode(['svn', 'merge', '-c', '-42', |
84 'random_file'], | 83 'random_file'], |
85 print_output=True).AndReturn([status, 0]) | 84 print_output=True).AndReturn([status, 0]) |
86 change = self.mox.CreateMockAnything() | 85 change = self.mox.CreateMockAnything() |
87 revert.gcl.ChangeInfo('revert42', 0, 0, 'Reverting 42.\n\nbleh', | 86 revert.gcl.ChangeInfo('revert42', 0, 0, 'Reverting 42.\n\nbleh', |
(...skipping 15 matching lines...) Expand all Loading... |
103 revert.sys.stdout.write(line) | 102 revert.sys.stdout.write(line) |
104 revert.sys.stdout.write('\n') | 103 revert.sys.stdout.write('\n') |
105 self.mox.ReplayAll() | 104 self.mox.ReplayAll() |
106 | 105 |
107 revert.Revert([42], True, True, False, 'bleh', ['foo@example.com']) | 106 revert.Revert([42], True, True, False, 'bleh', ['foo@example.com']) |
108 | 107 |
109 | 108 |
110 if __name__ == '__main__': | 109 if __name__ == '__main__': |
111 import unittest | 110 import unittest |
112 unittest.main() | 111 unittest.main() |
OLD | NEW |