| OLD | NEW |
| 1 #!/usr/bin/python | 1 #!/usr/bin/python |
| 2 # Copyright (c) 2010 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2010 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 gclient_scm.py.""" | 6 """Unit tests for gclient_scm.py.""" |
| 7 | 7 |
| 8 # pylint: disable=E1101,E1103,W0403 | 8 # pylint: disable=E1101,E1103,W0403 |
| 9 | 9 |
| 10 # Import before super_mox to keep valid references. | 10 # Import before super_mox to keep valid references. |
| (...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 161 ['update', '--revision', 'BASE', '--ignore-externals'], | 161 ['update', '--revision', 'BASE', '--ignore-externals'], |
| 162 cwd=self.base_path, | 162 cwd=self.base_path, |
| 163 file_list=mox.IgnoreArg()) | 163 file_list=mox.IgnoreArg()) |
| 164 | 164 |
| 165 self.mox.ReplayAll() | 165 self.mox.ReplayAll() |
| 166 scm = self._scm_wrapper(url=self.url, root_dir=self.root_dir, | 166 scm = self._scm_wrapper(url=self.url, root_dir=self.root_dir, |
| 167 relpath=self.relpath) | 167 relpath=self.relpath) |
| 168 file_list = [] | 168 file_list = [] |
| 169 scm.revert(options, self.args, file_list) | 169 scm.revert(options, self.args, file_list) |
| 170 | 170 |
| 171 def testRevert2Files(self): | |
| 172 options = self.Options(verbose=True) | |
| 173 gclient_scm.os.path.isdir(self.base_path).AndReturn(True) | |
| 174 items = [ | |
| 175 ('M ', 'a'), | |
| 176 ('A ', 'b'), | |
| 177 ] | |
| 178 file_path1 = join(self.base_path, 'a') | |
| 179 file_path2 = join(self.base_path, 'b') | |
| 180 gclient_scm.scm.SVN.CaptureStatus(self.base_path).AndReturn(items) | |
| 181 gclient_scm.os.path.exists(file_path1).AndReturn(True) | |
| 182 gclient_scm.os.path.isfile(file_path1).AndReturn(True) | |
| 183 gclient_scm.os.remove(file_path1) | |
| 184 gclient_scm.os.path.exists(file_path2).AndReturn(True) | |
| 185 gclient_scm.os.path.isfile(file_path2).AndReturn(True) | |
| 186 gclient_scm.os.remove(file_path2) | |
| 187 gclient_scm.scm.SVN.RunAndGetFileList( | |
| 188 options.verbose, | |
| 189 ['update', '--revision', 'BASE', '--ignore-externals'], | |
| 190 cwd=self.base_path, | |
| 191 file_list=mox.IgnoreArg()) | |
| 192 | |
| 193 self.mox.ReplayAll() | |
| 194 scm = self._scm_wrapper(url=self.url, root_dir=self.root_dir, | |
| 195 relpath=self.relpath) | |
| 196 file_list = [] | |
| 197 scm.revert(options, self.args, file_list) | |
| 198 self.checkstdout( | |
| 199 ('%s\n%s\n' % (join(self.base_path, 'a'), | |
| 200 join(self.base_path, 'b')))) | |
| 201 | |
| 202 def testRevertDirectory(self): | 171 def testRevertDirectory(self): |
| 203 options = self.Options(verbose=True) | 172 options = self.Options(verbose=True) |
| 204 gclient_scm.os.path.isdir(self.base_path).AndReturn(True) | 173 gclient_scm.os.path.isdir(self.base_path).AndReturn(True) |
| 205 items = [ | 174 items = [ |
| 206 ('~ ', 'a'), | 175 ('~ ', 'a'), |
| 207 ] | 176 ] |
| 208 gclient_scm.scm.SVN.CaptureStatus(self.base_path).AndReturn(items) | 177 gclient_scm.scm.SVN.CaptureStatus(self.base_path).AndReturn(items) |
| 209 file_path = join(self.base_path, 'a') | 178 file_path = join(self.base_path, 'a') |
| 210 gclient_scm.os.path.exists(file_path).AndReturn(True) | 179 gclient_scm.os.path.exists(file_path).AndReturn(True) |
| 211 gclient_scm.os.path.isfile(file_path).AndReturn(False) | 180 gclient_scm.os.path.isfile(file_path).AndReturn(False) |
| (...skipping 641 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 853 | 822 |
| 854 if __name__ == '__main__': | 823 if __name__ == '__main__': |
| 855 if '-v' in sys.argv: | 824 if '-v' in sys.argv: |
| 856 logging.basicConfig( | 825 logging.basicConfig( |
| 857 level=logging.DEBUG, | 826 level=logging.DEBUG, |
| 858 format='%(asctime).19s %(levelname)s %(filename)s:' | 827 format='%(asctime).19s %(levelname)s %(filename)s:' |
| 859 '%(lineno)s %(message)s') | 828 '%(lineno)s %(message)s') |
| 860 unittest.main() | 829 unittest.main() |
| 861 | 830 |
| 862 # vim: ts=2:sw=2:tw=80:et: | 831 # vim: ts=2:sw=2:tw=80:et: |
| OLD | NEW |