| 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') |
| 64 | 65 |
| 65 def testRevert(self): | 66 def testRevert(self): |
| 66 revert.gcl.GetRepositoryRoot().AndReturn('foo') | 67 revert.gcl.GetRepositoryRoot().AndReturn('foo') |
| 67 revert.os.chdir('foo') | 68 revert.os.chdir('foo') |
| 68 entries = [{ | 69 entries = [{ |
| 69 'author': 'Georges', | 70 'author': 'Georges', |
| 70 'paths': [ | 71 'paths': [ |
| 71 {'path': 'proto://fqdn/repo/random_file'} | 72 {'path': 'proto://fqdn/repo/random_file'} |
| 72 ], | 73 ], |
| 73 }] | 74 }] |
| 74 revert.CaptureSVNLog(['-r', '42', '-v']).AndReturn(entries) | 75 revert.CaptureSVNLog(['-r', '42', '-v']).AndReturn(entries) |
| 75 revert.GetRepoBase().AndReturn('proto://fqdn/repo/') | 76 revert.GetRepoBase().AndReturn('proto://fqdn/repo/') |
| 76 revert.gclient_scm.CaptureSVNStatus(['random_file']).AndReturn([]) | 77 revert.gclient_scm.scm.SVN.CaptureStatus(['random_file']).AndReturn([]) |
| 77 revert.gcl.RunShell(['svn', 'up', 'random_file']) | 78 revert.gcl.RunShell(['svn', 'up', 'random_file']) |
| 78 revert.os.path.isdir('random_file').AndReturn(False) | 79 revert.os.path.isdir('random_file').AndReturn(False) |
| 79 status = """--- Reverse-merging r42 into '.': | 80 status = """--- Reverse-merging r42 into '.': |
| 80 M random_file | 81 M random_file |
| 81 """ | 82 """ |
| 82 revert.gcl.RunShellWithReturnCode(['svn', 'merge', '-c', '-42', | 83 revert.gcl.RunShellWithReturnCode(['svn', 'merge', '-c', '-42', |
| 83 'random_file'], | 84 'random_file'], |
| 84 print_output=True).AndReturn([status, 0]) | 85 print_output=True).AndReturn([status, 0]) |
| 85 change = self.mox.CreateMockAnything() | 86 change = self.mox.CreateMockAnything() |
| 86 revert.gcl.ChangeInfo('revert42', 0, 0, 'Reverting 42.\n\nbleh', | 87 revert.gcl.ChangeInfo('revert42', 0, 0, 'Reverting 42.\n\nbleh', |
| (...skipping 15 matching lines...) Expand all Loading... |
| 102 revert.sys.stdout.write(line) | 103 revert.sys.stdout.write(line) |
| 103 revert.sys.stdout.write('\n') | 104 revert.sys.stdout.write('\n') |
| 104 self.mox.ReplayAll() | 105 self.mox.ReplayAll() |
| 105 | 106 |
| 106 revert.Revert([42], True, True, False, 'bleh', ['foo@example.com']) | 107 revert.Revert([42], True, True, False, 'bleh', ['foo@example.com']) |
| 107 | 108 |
| 108 | 109 |
| 109 if __name__ == '__main__': | 110 if __name__ == '__main__': |
| 110 import unittest | 111 import unittest |
| 111 unittest.main() | 112 unittest.main() |
| OLD | NEW |