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 1832 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1843 ((['DoGetTrySlaves'], ), None), | 1843 ((['DoGetTrySlaves'], ), None), |
1844 ((['SetCQState', git_cl._CQState.DRY_RUN], ), None), | 1844 ((['SetCQState', git_cl._CQState.DRY_RUN], ), None), |
1845 ] | 1845 ] |
1846 out = StringIO.StringIO() | 1846 out = StringIO.StringIO() |
1847 self.mock(git_cl.sys, 'stdout', out) | 1847 self.mock(git_cl.sys, 'stdout', out) |
1848 self.assertEqual(0, git_cl.main(['try'])) | 1848 self.assertEqual(0, git_cl.main(['try'])) |
1849 self.assertEqual( | 1849 self.assertEqual( |
1850 out.getvalue(), | 1850 out.getvalue(), |
1851 'scheduled CQ Dry Run on https://codereview.chromium.org/123\n') | 1851 'scheduled CQ Dry Run on https://codereview.chromium.org/123\n') |
1852 | 1852 |
1853 def test_git_cl_try_results_json(self): | |
1854 # out = | |
1855 # self.mock(git_cl.sys, 'stdout', out) | |
1856 self.mock(git_cl.Changelist, 'GetMostRecentPatchset', lambda *_: 1) | |
1857 self.calls = [ | |
1858 ((['git', 'symbolic-ref', 'HEAD'],), 'refs/heads/my-branch'), | |
1859 ((['git', 'config', 'branch.my-branch.rietveldissue'],), '123'), | |
1860 ((['git', 'config', 'rietveld.autoupdate'],), ''), | |
1861 ((['git', 'config', 'rietveld.server'],), | |
1862 'https://codereview.chromium.org'), | |
1863 ((['git', 'config', 'branch.my-branch.rietveldpatchset'],), '1'), | |
1864 ((['git', 'config', 'branch.my-branch.merge'],), 'feature'), | |
1865 ((['git', 'config', 'branch.my-branch.remote'],), 'origin'), | |
1866 (('write_json', | |
1867 'output.json', | |
1868 {'issue': 123, | |
1869 'issue_url': 'https://codereview.chromium.org/123'}), '') | |
1870 ] | |
1871 pass | |
iannucci
2016/08/26 18:21:13
this test doesn't look like it tests anything? It
qyearsley
2016/08/26 18:32:13
Yeah, the test isn't written properly yet, I uploa
| |
1872 | |
1853 def _common_GerritCommitMsgHookCheck(self): | 1873 def _common_GerritCommitMsgHookCheck(self): |
1854 self.mock(git_cl.sys, 'stdout', StringIO.StringIO()) | 1874 self.mock(git_cl.sys, 'stdout', StringIO.StringIO()) |
1855 self.mock(git_cl.os.path, 'abspath', | 1875 self.mock(git_cl.os.path, 'abspath', |
1856 lambda path: self._mocked_call(['abspath', path])) | 1876 lambda path: self._mocked_call(['abspath', path])) |
1857 self.mock(git_cl.os.path, 'exists', | 1877 self.mock(git_cl.os.path, 'exists', |
1858 lambda path: self._mocked_call(['exists', path])) | 1878 lambda path: self._mocked_call(['exists', path])) |
1859 self.mock(git_cl.gclient_utils, 'FileRead', | 1879 self.mock(git_cl.gclient_utils, 'FileRead', |
1860 lambda path: self._mocked_call(['FileRead', path])) | 1880 lambda path: self._mocked_call(['FileRead', path])) |
1861 self.mock(git_cl.gclient_utils, 'rm_file_or_tree', | 1881 self.mock(git_cl.gclient_utils, 'rm_file_or_tree', |
1862 lambda path: self._mocked_call(['rm_file_or_tree', path])) | 1882 lambda path: self._mocked_call(['rm_file_or_tree', path])) |
(...skipping 29 matching lines...) Expand all Loading... | |
1892 ((['rm_file_or_tree', '/abs/git_repo_root/.git/hooks/commit-msg'],), | 1912 ((['rm_file_or_tree', '/abs/git_repo_root/.git/hooks/commit-msg'],), |
1893 ''), | 1913 ''), |
1894 ] | 1914 ] |
1895 cl._codereview_impl._GerritCommitMsgHookCheck(offer_removal=True) | 1915 cl._codereview_impl._GerritCommitMsgHookCheck(offer_removal=True) |
1896 | 1916 |
1897 | 1917 |
1898 if __name__ == '__main__': | 1918 if __name__ == '__main__': |
1899 git_cl.logging.basicConfig( | 1919 git_cl.logging.basicConfig( |
1900 level=git_cl.logging.DEBUG if '-v' in sys.argv else git_cl.logging.ERROR) | 1920 level=git_cl.logging.DEBUG if '-v' in sys.argv else git_cl.logging.ERROR) |
1901 unittest.main() | 1921 unittest.main() |
OLD | NEW |