| OLD | NEW |
| 1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
| 2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2012 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 git_cl.py.""" | 6 """Unit tests for git_cl.py.""" |
| 7 | 7 |
| 8 import os | 8 import os |
| 9 import StringIO | 9 import StringIO |
| 10 import stat | 10 import stat |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 89 self.mock(git_cl, 'FindCodereviewSettingsFile', lambda: '') | 89 self.mock(git_cl, 'FindCodereviewSettingsFile', lambda: '') |
| 90 self.mock(git_cl, 'ask_for_data', self._mocked_call) | 90 self.mock(git_cl, 'ask_for_data', self._mocked_call) |
| 91 self.mock(git_cl.breakpad, 'post', self._mocked_call) | 91 self.mock(git_cl.breakpad, 'post', self._mocked_call) |
| 92 self.mock(git_cl.breakpad, 'SendStack', self._mocked_call) | 92 self.mock(git_cl.breakpad, 'SendStack', self._mocked_call) |
| 93 self.mock(git_cl.presubmit_support, 'DoPresubmitChecks', PresubmitMock) | 93 self.mock(git_cl.presubmit_support, 'DoPresubmitChecks', PresubmitMock) |
| 94 self.mock(git_cl.rietveld, 'Rietveld', RietveldMock) | 94 self.mock(git_cl.rietveld, 'Rietveld', RietveldMock) |
| 95 self.mock(git_cl.rietveld, 'CachingRietveld', RietveldMock) | 95 self.mock(git_cl.rietveld, 'CachingRietveld', RietveldMock) |
| 96 self.mock(git_cl.upload, 'RealMain', self.fail) | 96 self.mock(git_cl.upload, 'RealMain', self.fail) |
| 97 self.mock(git_cl.watchlists, 'Watchlists', WatchlistsMock) | 97 self.mock(git_cl.watchlists, 'Watchlists', WatchlistsMock) |
| 98 self.mock(git_cl.auth, 'get_authenticator_for_host', AuthenticatorMock) | 98 self.mock(git_cl.auth, 'get_authenticator_for_host', AuthenticatorMock) |
| 99 self.mock(git_cl.auth, '_should_use_oauth2', lambda: False) |
| 99 # It's important to reset settings to not have inter-tests interference. | 100 # It's important to reset settings to not have inter-tests interference. |
| 100 git_cl.settings = None | 101 git_cl.settings = None |
| 101 | 102 |
| 102 def tearDown(self): | 103 def tearDown(self): |
| 103 if not self.has_failed(): | 104 if not self.has_failed(): |
| 104 self.assertEquals([], self.calls) | 105 self.assertEquals([], self.calls) |
| 105 super(TestGitCl, self).tearDown() | 106 super(TestGitCl, self).tearDown() |
| 106 | 107 |
| 107 def _mocked_call(self, *args, **_kwargs): | 108 def _mocked_call(self, *args, **_kwargs): |
| 108 self.assertTrue( | 109 self.assertTrue( |
| (...skipping 741 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 850 # Check target refs for pending prefix. | 851 # Check target refs for pending prefix. |
| 851 self.assertEqual('prefix/heads/master', | 852 self.assertEqual('prefix/heads/master', |
| 852 git_cl.GetTargetRef('origin', 'refs/remotes/origin/master', | 853 git_cl.GetTargetRef('origin', 'refs/remotes/origin/master', |
| 853 None, 'prefix/')) | 854 None, 'prefix/')) |
| 854 | 855 |
| 855 | 856 |
| 856 if __name__ == '__main__': | 857 if __name__ == '__main__': |
| 857 git_cl.logging.basicConfig( | 858 git_cl.logging.basicConfig( |
| 858 level=git_cl.logging.DEBUG if '-v' in sys.argv else git_cl.logging.ERROR) | 859 level=git_cl.logging.DEBUG if '-v' in sys.argv else git_cl.logging.ERROR) |
| 859 unittest.main() | 860 unittest.main() |
| OLD | NEW |