Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(404)

Side by Side Diff: tests/gclient_test.py

Issue 214005: gclient_scm: add a new test case for SCMWrapper.revert (Closed)
Patch Set: tiny cleanup Created 11 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #!/usr/bin/python 1 #!/usr/bin/python
2 # 2 #
3 # Copyright 2008-2009 Google Inc. All Rights Reserved. 3 # Copyright 2008-2009 Google Inc. All Rights Reserved.
4 # 4 #
5 # Licensed under the Apache License, Version 2.0 (the "License"); 5 # Licensed under the Apache License, Version 2.0 (the "License");
6 # you may not use this file except in compliance with the License. 6 # you may not use this file except in compliance with the License.
7 # You may obtain a copy of the License at 7 # You may obtain a copy of the License at
8 # 8 #
9 # http://www.apache.org/licenses/LICENSE-2.0 9 # http://www.apache.org/licenses/LICENSE-2.0
10 # 10 #
(...skipping 18 matching lines...) Expand all
29 import gclient_utils 29 import gclient_utils
30 import super_mox 30 import super_mox
31 from super_mox import mox 31 from super_mox import mox
32 32
33 33
34 class BaseTestCase(super_mox.SuperMoxTestBase): 34 class BaseTestCase(super_mox.SuperMoxTestBase):
35 def setUp(self): 35 def setUp(self):
36 super_mox.SuperMoxTestBase.setUp(self) 36 super_mox.SuperMoxTestBase.setUp(self)
37 self.mox.StubOutWithMock(gclient.os.path, 'exists') 37 self.mox.StubOutWithMock(gclient.os.path, 'exists')
38 self.mox.StubOutWithMock(gclient.os.path, 'isdir') 38 self.mox.StubOutWithMock(gclient.os.path, 'isdir')
39 self.mox.StubOutWithMock(gclient.os, 'remove')
39 self.mox.StubOutWithMock(gclient.sys, 'stdout') 40 self.mox.StubOutWithMock(gclient.sys, 'stdout')
40 self.mox.StubOutWithMock(gclient_utils, 'subprocess') 41 self.mox.StubOutWithMock(gclient_utils, 'subprocess')
41 # These are not tested. 42 # These are not tested.
42 self.mox.StubOutWithMock(gclient, 'FileRead') 43 self.mox.StubOutWithMock(gclient, 'FileRead')
43 self.mox.StubOutWithMock(gclient, 'FileWrite') 44 self.mox.StubOutWithMock(gclient, 'FileWrite')
44 self.mox.StubOutWithMock(gclient_utils, 'SubprocessCall') 45 self.mox.StubOutWithMock(gclient_utils, 'SubprocessCall')
45 self.mox.StubOutWithMock(gclient_utils, 'RemoveDirectory') 46 self.mox.StubOutWithMock(gclient_utils, 'RemoveDirectory')
46 47
47 # Like unittest's assertRaises, but checks for Gclient.Error. 48 # Like unittest's assertRaises, but checks for Gclient.Error.
48 def assertRaisesError(self, msg, fn, *args, **kwargs): 49 def assertRaisesError(self, msg, fn, *args, **kwargs):
(...skipping 1061 matching lines...) Expand 10 before | Expand all | Expand 10 after
1110 print(os.path.join(base_path, 'a')) 1111 print(os.path.join(base_path, 'a'))
1111 print(os.path.join(base_path, 'b')) 1112 print(os.path.join(base_path, 'b'))
1112 gclient_scm.RunSVN(['revert', 'a', 'b'], base_path) 1113 gclient_scm.RunSVN(['revert', 'a', 'b'], base_path)
1113 1114
1114 self.mox.ReplayAll() 1115 self.mox.ReplayAll()
1115 scm = self._scm_wrapper(url=self.url, root_dir=self.root_dir, 1116 scm = self._scm_wrapper(url=self.url, root_dir=self.root_dir,
1116 relpath=self.relpath) 1117 relpath=self.relpath)
1117 file_list = [] 1118 file_list = []
1118 scm.revert(options, self.args, file_list) 1119 scm.revert(options, self.args, file_list)
1119 1120
1121 def testRevertUnversionedUnexpectedFile(self):
1122 options = self.Options(verbose=True)
1123 base_path = os.path.join(self.root_dir, self.relpath)
1124 gclient.os.path.isdir(base_path).AndReturn(True)
1125 items = [
1126 ('~ ', 'a'),
1127 ]
1128 gclient_scm.CaptureSVNStatus(base_path).AndReturn(items)
1129 file_path = os.path.join(base_path, 'a')
1130 print(file_path)
1131 gclient_scm.os.remove(file_path).AndRaise(EnvironmentError())
1132 gclient_utils.RemoveDirectory(file_path)
1133 gclient_scm.RunSVN(['revert', 'a'], base_path)
1134
1135 self.mox.ReplayAll()
1136 scm = self._scm_wrapper(url=self.url, root_dir=self.root_dir,
1137 relpath=self.relpath)
1138 file_list = []
1139 scm.revert(options, self.args, file_list)
1140
1120 def testStatus(self): 1141 def testStatus(self):
1121 options = self.Options(verbose=True) 1142 options = self.Options(verbose=True)
1122 base_path = os.path.join(self.root_dir, self.relpath) 1143 base_path = os.path.join(self.root_dir, self.relpath)
1123 gclient.os.path.isdir(base_path).AndReturn(True) 1144 gclient.os.path.isdir(base_path).AndReturn(True)
1124 gclient_scm.RunSVNAndGetFileList(['status'] + self.args, base_path, 1145 gclient_scm.RunSVNAndGetFileList(['status'] + self.args, base_path,
1125 []).AndReturn(None) 1146 []).AndReturn(None)
1126 1147
1127 self.mox.ReplayAll() 1148 self.mox.ReplayAll()
1128 scm = self._scm_wrapper(url=self.url, root_dir=self.root_dir, 1149 scm = self._scm_wrapper(url=self.url, root_dir=self.root_dir,
1129 relpath=self.relpath) 1150 relpath=self.relpath)
(...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after
1382 """ 1403 """
1383 gclient_scm.CaptureSVN = CaptureSVNMock 1404 gclient_scm.CaptureSVN = CaptureSVNMock
1384 info = gclient_scm.CaptureSVNStatus(None) 1405 info = gclient_scm.CaptureSVNStatus(None)
1385 self.assertEquals(info, []) 1406 self.assertEquals(info, [])
1386 1407
1387 1408
1388 if __name__ == '__main__': 1409 if __name__ == '__main__':
1389 unittest.main() 1410 unittest.main()
1390 1411
1391 # vim: ts=2:sw=2:tw=80:et: 1412 # vim: ts=2:sw=2:tw=80:et:
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698