From c13c5ff5a4b7aefb67204a6fb89b4181ae8b3b02 Mon Sep 17 00:00:00 2001 From: "maruel@chromium.org" Date: Tue, 22 Sep 2009 13:03:39 +0000 Subject: [PATCH] Fix gclient unittests. BUG=none TEST=unittests Review URL: http://codereview.chromium.org/215039 git-svn-id: svn://svn.chromium.org/chrome/trunk/tools/depot_tools@26804 0039d316-1c4b-4281-b951-d872f2087c98 --- tests/gclient_test.py | 34 +++++++++++++++++++++++----------- 1 file changed, 23 insertions(+), 11 deletions(-) diff --git a/tests/gclient_test.py b/tests/gclient_test.py index 8d9295cd2..479add60b 100644 --- a/tests/gclient_test.py +++ b/tests/gclient_test.py @@ -35,6 +35,7 @@ class BaseTestCase(super_mox.SuperMoxTestBase): def setUp(self): super_mox.SuperMoxTestBase.setUp(self) self.mox.StubOutWithMock(gclient.os.path, 'exists') + self.mox.StubOutWithMock(gclient.os.path, 'isfile') self.mox.StubOutWithMock(gclient.os.path, 'isdir') self.mox.StubOutWithMock(gclient.os, 'remove') self.mox.StubOutWithMock(gclient.sys, 'stdout') @@ -1091,6 +1092,8 @@ class SCMWrapperTestCase(GClientBaseTestCase): base_path = os.path.join(self.root_dir, self.relpath) gclient.os.path.isdir(base_path).AndReturn(True) gclient_scm.CaptureSVNStatus(base_path).AndReturn([]) + gclient_scm.RunSVNAndGetFileList(['update', '--revision', 'BASE'], base_path, + mox.IgnoreArg()) self.mox.ReplayAll() scm = self._scm_wrapper(url=self.url, root_dir=self.root_dir, @@ -1106,21 +1109,27 @@ class SCMWrapperTestCase(GClientBaseTestCase): ('M ', 'a'), ('A ', 'b'), ] + file_path1 = os.path.join(base_path, 'a') + file_path2 = os.path.join(base_path, 'b') gclient_scm.CaptureSVNStatus(base_path).AndReturn(items) - + gclient_scm.os.path.exists(file_path1).AndReturn(True) + gclient_scm.os.path.isfile(file_path1).AndReturn(True) + gclient_scm.os.remove(file_path1) + gclient_scm.os.path.exists(file_path2).AndReturn(True) + gclient_scm.os.path.isfile(file_path2).AndReturn(True) + gclient_scm.os.remove(file_path2) + gclient_scm.RunSVNAndGetFileList(['update', '--revision', 'BASE'], base_path, + mox.IgnoreArg()) print(os.path.join(base_path, 'a')) print(os.path.join(base_path, 'b')) - gclient_scm.RunSVN(['revert', 'a', 'b'], base_path) self.mox.ReplayAll() scm = self._scm_wrapper(url=self.url, root_dir=self.root_dir, relpath=self.relpath) file_list = [] scm.revert(options, self.args, file_list) - self.assertEquals(sorted(file_list), sorted([os.path.join(base_path, 'a'), - os.path.join(base_path, 'b')])) - def testRevertUnversionedUnexpectedFile(self): + def testRevertDirectory(self): options = self.Options(verbose=True) base_path = os.path.join(self.root_dir, self.relpath) gclient.os.path.isdir(base_path).AndReturn(True) @@ -1130,17 +1139,20 @@ class SCMWrapperTestCase(GClientBaseTestCase): gclient_scm.CaptureSVNStatus(base_path).AndReturn(items) file_path = os.path.join(base_path, 'a') print(file_path) - gclient_scm.os.remove(file_path).AndRaise(EnvironmentError()) + gclient_scm.os.path.exists(file_path).AndReturn(True) + gclient_scm.os.path.isfile(file_path).AndReturn(False) + gclient_scm.os.path.isdir(file_path).AndReturn(True) + #gclient_scm.os.remove(file_path) gclient_utils.RemoveDirectory(file_path) - gclient_scm.RunSVN(['revert', 'a'], base_path) + file_list1 = [] + gclient_scm.RunSVNAndGetFileList(['update', '--revision', 'BASE'], base_path, + mox.IgnoreArg()) self.mox.ReplayAll() scm = self._scm_wrapper(url=self.url, root_dir=self.root_dir, relpath=self.relpath) - file_list = [] - scm.revert(options, self.args, file_list) - # TODO(msb): fix bug (file_list contains dupes) and enable assertion - #self.assertEquals(file_list, [os.path.join(base_path, 'a')]) + file_list2 = [] + scm.revert(options, self.args, file_list2) def testStatus(self): options = self.Options(verbose=True)