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

Unified Diff: tests/gcl_unittest.py

Issue 113269: Add more tests and cleanup ChangeInfo class. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/depot_tools/
Patch Set: '' Created 11 years, 7 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 | « gcl.py ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/gcl_unittest.py
===================================================================
--- tests/gcl_unittest.py (revision 15878)
+++ tests/gcl_unittest.py (working copy)
@@ -5,7 +5,9 @@
"""Unit tests for gcl.py."""
+import StringIO
import os
+import sys
import unittest
# Local imports
@@ -56,8 +58,7 @@
'UnknownFiles', 'UploadCL', 'Warn', 'WriteFile', 'gcl_info_dir',
'getpass', 'main', 'os', 'random', 're', 'read_gcl_info',
'repository_root', 'string', 'subprocess', 'sys', 'tempfile', 'upload',
- 'urllib2', 'use_shell', 'xml',
-
+ 'urllib2', 'xml',
]
# If this test fails, you should add the relevant test.
self.compareMembers(gcl, members)
@@ -79,6 +80,7 @@
</entry>
</info>
""" % command[3]
+ # GclTestsBase.tearDown will restore the original.
gcl.RunShell = RunShellMock
filename = os.path.join('app', 'd')
info = gcl.GetSVNFileInfo(filename)
@@ -132,6 +134,7 @@
</target>
</status>
"""
+ # GclTestsBase.tearDown will restore the original.
gcl.RunShell = RunShellMock
info = gcl.GetSVNStatus('.')
expected = [
@@ -152,10 +155,52 @@
</target>
</status>
"""
+ # GclTestsBase.tearDown will restore the original.
gcl.RunShell = RunShellMock
info = gcl.GetSVNStatus(None)
self.assertEquals(info, [])
+ def testHelp(self):
+ old_stdout = sys.stdout
+ try:
+ dummy = StringIO.StringIO()
+ gcl.sys.stdout = dummy
+ gcl.Help()
+ self.assertEquals(len(dummy.getvalue()), 1718)
+ finally:
+ gcl.sys.stdout = old_stdout
+ def testGetRepositoryRoot(self):
+ try:
+ def RunShellMock(filename):
+ return '<?xml version="1.0"?>\n<info>'
+ gcl.RunShell = RunShellMock
+ gcl.GetRepositoryRoot()
+ except Exception,e:
+ self.assertEquals(e.args[0], "gcl run outside of repository")
+ pass
+
+
+class ChangeInfoUnittest(GclTestsBase):
+ def testChangeInfoMembers(self):
+ members = [
+ 'CloseIssue', 'Delete', 'FileList', 'MissingTests', 'Save',
+ 'UpdateRietveldDescription', 'description', 'files', 'issue', 'name',
+ 'patch'
+ ]
+ # If this test fails, you should add the relevant test.
+ self.compareMembers(gcl.ChangeInfo(), members)
+
+ def testChangeInfoBase(self):
+ files = [('M', 'foo'), ('A', 'bar')]
+ o = gcl.ChangeInfo('name2', 'issue2', 'description2', files)
+ self.assertEquals(o.name, 'name2')
+ self.assertEquals(o.issue, 'issue2')
+ self.assertEquals(o.description, 'description2')
+ self.assertEquals(o.files, files)
+ self.assertEquals(o.patch, None)
+ self.assertEquals(o.FileList(), ['foo', 'bar'])
+
+
if __name__ == '__main__':
unittest.main()
« no previous file with comments | « gcl.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698