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

Unified Diff: tests/trychange_unittest.py

Issue 248029: Make the try slave selection client side. (Closed) Base URL: svn://chrome-svn/chrome/trunk/tools/depot_tools/
Patch Set: 80 columns Created 11 years, 2 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « tests/presubmit_unittest.py ('k') | trychange.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/trychange_unittest.py
===================================================================
--- tests/trychange_unittest.py (revision 28147)
+++ tests/trychange_unittest.py (working copy)
@@ -5,11 +5,14 @@
"""Unit tests for trychange.py."""
+import optparse
import unittest
# Local imports
+import gcl
import super_mox
import trychange
+import upload
from super_mox import mox
@@ -27,8 +30,8 @@
'HELP_STRING', 'InvalidScript', 'NoTryServerAccess', 'PathDifference',
'RunCommand', 'SCM', 'SVN', 'TryChange', 'USAGE',
'datetime', 'gcl', 'gclient', 'gclient_scm', 'getpass', 'logging',
- 'optparse', 'os', 'shutil', 'socket', 'sys', 'tempfile', 'traceback',
- 'upload', 'urllib', 'subprocess',
+ 'optparse', 'os', 'presubmit_support', 'shutil', 'socket', 'subprocess',
+ 'sys', 'tempfile', 'traceback', 'upload', 'urllib',
]
# If this test fails, you should add the relevant test.
self.compareMembers(trychange, members)
@@ -36,23 +39,62 @@
class SVNUnittest(TryChangeTestsBase):
"""trychange.SVN tests."""
+ def setUp(self):
+ self.fake_root = '/fake_root'
+ self.expected_files = ['foo.txt', 'bar.txt']
+ change_info = gcl.ChangeInfo('test_change', 0, 0, 'desc',
+ [('M', f) for f in self.expected_files],
+ self.fake_root)
+ self.svn = trychange.SVN(None)
+ self.svn.change_info = change_info
+ super_mox.SuperMoxTestBase.setUp(self)
+
def testMembersChanged(self):
members = [
- 'GenerateDiff', 'ProcessOptions', 'options'
+ 'GenerateDiff', 'GetFileNames', 'GetLocalRoot', 'ProcessOptions',
+ 'options'
]
# If this test fails, you should add the relevant test.
self.compareMembers(trychange.SVN(None), members)
+ def testGetFileNames(self):
+ self.mox.ReplayAll()
+ self.assertEqual(self.svn.GetFileNames(), self.expected_files)
+ def testGetLocalRoot(self):
+ self.mox.ReplayAll()
+ self.assertEqual(self.svn.GetLocalRoot(), self.fake_root)
+
+
class GITUnittest(TryChangeTestsBase):
"""trychange.GIT tests."""
+ def setUp(self):
+ self.fake_root = '/fake_root'
+ self.expected_files = ['foo.txt', 'bar.txt']
+ options = optparse.Values()
+ options.files = self.expected_files
+ self.git = trychange.GIT(options)
+ super_mox.SuperMoxTestBase.setUp(self)
+
def testMembersChanged(self):
members = [
- 'GenerateDiff', 'GetEmail', 'GetPatchName', 'ProcessOptions', 'options'
+ 'GenerateDiff', 'GetEmail', 'GetFileNames', 'GetLocalRoot',
+ 'GetPatchName', 'ProcessOptions', 'options'
]
# If this test fails, you should add the relevant test.
self.compareMembers(trychange.GIT(None), members)
+ def testGetFileNames(self):
+ self.mox.ReplayAll()
+ self.assertEqual(self.git.GetFileNames(), self.expected_files)
+ def testGetLocalRoot(self):
+ self.mox.StubOutWithMock(upload, 'RunShell')
+ upload.RunShell(['git', 'rev-parse', '--show-cdup']).AndReturn(
+ self.fake_root)
+ self.mox.ReplayAll()
+ self.assertEqual(self.git.GetLocalRoot(), self.fake_root)
+
+
if __name__ == '__main__':
unittest.main()
« no previous file with comments | « tests/presubmit_unittest.py ('k') | trychange.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698