summaryrefslogtreecommitdiffstats
path: root/PRESUBMIT_test_mocks.py
diff options
context:
space:
mode:
authordavileen <davileen@amazon.com>2015-03-02 13:10:41 -0800
committerCommit bot <commit-bot@chromium.org>2015-03-02 21:11:31 +0000
commite0426257f867edcef07a156152c61ac01c490dda (patch)
tree4e8baf3b2e7d51ccfbe357005cf10c061a748a6f /PRESUBMIT_test_mocks.py
parent0d149cf3d79089c25fbe69bbee6c187fe88358a2 (diff)
downloadchromium_src-e0426257f867edcef07a156152c61ac01c490dda.zip
chromium_src-e0426257f867edcef07a156152c61ac01c490dda.tar.gz
chromium_src-e0426257f867edcef07a156152c61ac01c490dda.tar.bz2
Add PRESUBMIT tests for _CheckUserActionUpdate function.
Presubmit does not contain any tests for the _CheckUserActionUpdate function. This commit adds a test to check against an action in actions.xml and one that is not found there. To do this we have to improve the MockInputApi and MockFile classes. BUG=462814 Review URL: https://codereview.chromium.org/966703003 Cr-Commit-Position: refs/heads/master@{#318759}
Diffstat (limited to 'PRESUBMIT_test_mocks.py')
-rw-r--r--PRESUBMIT_test_mocks.py19
1 files changed, 15 insertions, 4 deletions
diff --git a/PRESUBMIT_test_mocks.py b/PRESUBMIT_test_mocks.py
index 03d9232..8e15d8c 100644
--- a/PRESUBMIT_test_mocks.py
+++ b/PRESUBMIT_test_mocks.py
@@ -32,6 +32,9 @@ class MockInputApi(object):
def AffectedSourceFiles(self, file_filter=None):
return self.files
+ def LocalPaths(self):
+ return self.files
+
def PresubmitLocalPath(self):
return os.path.dirname(__file__)
@@ -62,22 +65,22 @@ class MockOutputApi(object):
return self.message
class PresubmitError(PresubmitResult):
- def __init__(self, message, items, long_text=''):
+ def __init__(self, message, items=None, long_text=''):
MockOutputApi.PresubmitResult.__init__(self, message, items, long_text)
self.type = 'error'
class PresubmitPromptWarning(PresubmitResult):
- def __init__(self, message, items, long_text=''):
+ def __init__(self, message, items=None, long_text=''):
MockOutputApi.PresubmitResult.__init__(self, message, items, long_text)
self.type = 'warning'
class PresubmitNotifyResult(PresubmitResult):
- def __init__(self, message, items, long_text=''):
+ def __init__(self, message, items=None, long_text=''):
MockOutputApi.PresubmitResult.__init__(self, message, items, long_text)
self.type = 'notify'
class PresubmitPromptOrNotify(PresubmitResult):
- def __init__(self, message, items, long_text=''):
+ def __init__(self, message, items=None, long_text=''):
MockOutputApi.PresubmitResult.__init__(self, message, items, long_text)
self.type = 'promptOrNotify'
@@ -103,6 +106,14 @@ class MockFile(object):
def LocalPath(self):
return self._local_path
+ def rfind(self, p):
+ """os.path.basename is called on MockFile so we need an rfind method."""
+ return self._local_path.rfind(p)
+
+ def __getitem__(self, i):
+ """os.path.basename is called on MockFile so we need a get method."""
+ return self._local_path[i]
+
class MockAffectedFile(MockFile):
def AbsoluteLocalPath(self):