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

Unified Diff: tests/presubmit_unittest.py

Issue 3107038: Adding json based tree open check. (Closed) Base URL: svn://chrome-svn/chrome/trunk/tools/depot_tools/
Patch Set: '' Created 10 years, 4 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 | « presubmit_canned_checks.py ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/presubmit_unittest.py
===================================================================
--- tests/presubmit_unittest.py (revision 57418)
+++ tests/presubmit_unittest.py (working copy)
@@ -71,8 +71,8 @@
'SvnAffectedFile', 'SvnChange', 'cPickle', 'cStringIO',
'exceptions', 'fnmatch', 'gcl', 'gclient_utils', 'glob', 'json',
'logging', 'marshal', 'normpath', 'optparse', 'os', 'pickle',
- 'presubmit_canned_checks', 'random', 're', 'scm', 'subprocess', 'sys',
- 'tempfile', 'time', 'traceback', 'types', 'unittest', 'urllib2',
+ 'presubmit_canned_checks', 'random', 're', 'scm', 'subprocess',
+ 'sys', 'tempfile', 'time', 'traceback', 'types', 'unittest', 'urllib2',
'warnings',
]
# If this test fails, you should add the relevant test.
@@ -616,9 +616,8 @@
'PresubmitLocalPath', 'ReadFile', 'RightHandSideLines', 'ServerPaths',
'basename', 'cPickle', 'cStringIO', 'canned_checks', 'change', 'environ',
'is_committing', 'json', 'marshal', 'os_path', 'pickle', 'platform',
- 'python_executable',
- 're', 'subprocess', 'tempfile', 'traceback', 'unittest', 'urllib2',
- 'version',
+ 'python_executable', 're', 'subprocess', 'tempfile', 'traceback',
+ 'unittest', 'urllib2', 'version',
]
# If this test fails, you should add the relevant test.
self.compareMembers(presubmit.InputApi(None, './.', False), members)
@@ -1507,26 +1506,63 @@
input_api = self.MockInputApi(None, True)
connection = self.mox.CreateMockAnything()
input_api.urllib2.urlopen('url_to_open').AndReturn(connection)
- connection.read().AndReturn('1')
+ connection.read().AndReturn('The tree is open')
connection.close()
self.mox.ReplayAll()
results = presubmit_canned_checks.CheckTreeIsOpen(
- input_api, presubmit.OutputApi, url='url_to_open', closed='0')
+ input_api, presubmit.OutputApi, url='url_to_open', closed='.*closed.*')
self.assertEquals(results, [])
def testCannedCheckTreeIsOpenClosed(self):
input_api = self.MockInputApi(None, True)
connection = self.mox.CreateMockAnything()
input_api.urllib2.urlopen('url_to_closed').AndReturn(connection)
- connection.read().AndReturn('0')
+ connection.read().AndReturn('Tree is closed for maintenance')
connection.close()
self.mox.ReplayAll()
results = presubmit_canned_checks.CheckTreeIsOpen(
- input_api, presubmit.OutputApi, url='url_to_closed', closed='0')
+ input_api, presubmit.OutputApi,
+ url='url_to_closed', closed='.*closed.*')
self.assertEquals(len(results), 1)
self.assertEquals(results[0].__class__,
presubmit.OutputApi.PresubmitError)
+ def testCannedCheckJsonTreeIsOpenOpen(self):
+ input_api = self.MockInputApi(None, True)
+ input_api.json = presubmit.json
+ connection = self.mox.CreateMockAnything()
+ input_api.urllib2.urlopen('url_to_open').AndReturn(connection)
+ status = {
+ 'can_commit_freely': True,
+ 'general_state': 'open',
+ 'message': 'The tree is open'
+ }
+ connection.read().AndReturn(input_api.json.dumps(status))
+ connection.close()
+ self.mox.ReplayAll()
+ results = presubmit_canned_checks.CheckTreeIsOpen(
+ input_api, presubmit.OutputApi, json_url='url_to_open')
+ self.assertEquals(results, [])
+
+ def testCannedCheckJsonTreeIsOpenClosed(self):
+ input_api = self.MockInputApi(None, True)
+ input_api.json = presubmit.json
+ connection = self.mox.CreateMockAnything()
+ input_api.urllib2.urlopen('url_to_closed').AndReturn(connection)
+ status = {
+ 'can_commit_freely': False,
+ 'general_state': 'closed',
+ 'message': 'The tree is close',
+ }
+ connection.read().AndReturn(input_api.json.dumps(status))
+ connection.close()
+ self.mox.ReplayAll()
+ results = presubmit_canned_checks.CheckTreeIsOpen(
+ input_api, presubmit.OutputApi, json_url='url_to_closed')
+ self.assertEquals(len(results), 1)
+ self.assertEquals(results[0].__class__,
+ presubmit.OutputApi.PresubmitError)
+
def testRunPythonUnitTestsNoTest(self):
input_api = self.MockInputApi(None, False)
self.mox.ReplayAll()
« no previous file with comments | « presubmit_canned_checks.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698