Chromium Code Reviews| Index: third_party/WebKit/LayoutTests/imported/PRESUBMIT_test.py |
| diff --git a/third_party/WebKit/LayoutTests/imported/PRESUBMIT_test.py b/third_party/WebKit/LayoutTests/imported/PRESUBMIT_test.py |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..baaf9cf814cd078ac340c24143f4e2e8e3aff727 |
| --- /dev/null |
| +++ b/third_party/WebKit/LayoutTests/imported/PRESUBMIT_test.py |
| @@ -0,0 +1,51 @@ |
| +# Copyright (c) 2016 The Chromium Authors. All rights reserved. |
| +# Use of this source code is governed by a BSD-style license that can be |
| +# found in the LICENSE file. |
| + |
| +from PRESUBMIT import PostUploadHook |
| +import unittest |
| +# TODO: how to run the tests so this is imported correctly? |
|
foolip
2016/11/17 09:59:14
TODO(jeffcarp)
|
| +# from PRESUBMIT_test_mocks import MockOutputApi # pylint: disable=F0401 |
|
qyearsley
2016/11/17 00:23:27
I think you'd have to add something to the effect
|
| + |
| + |
| +class PresubmitTest(unittest.TestCase): |
| + |
| + def test_adds_WPTEXPORT_true_if_not_exists(self): |
| + mock['description'] = 'mock description' |
| + PostUploadHook(MockCL(), None, MockOutputAPI()) |
| + self.assertIn('WPTEXPORT=true', mock['description']) |
| + |
| + def test_doesnt_add_WPTEXPORT_if_exists(self): |
| + mock['description'] = 'mock description\nWPTEXPORT=false' |
| + PostUploadHook(MockCL(), None, MockOutputAPI()) |
| + self.assertIn('WPTEXPORT=false', mock['description']) |
| + |
| + |
| +# TODO: Couldn't figure out how to mock this without using a global variable |
|
qyearsley
2016/11/17 00:23:27
How about making the MockCL constructor take a des
|
| +mock = { 'description': '' } |
| + |
| + |
| +class MockCL(object): |
| + # TODO(jeffcarp): add to PRESUBMIT_test_mocks |
| + |
| + def __init__(self): |
| + self.issue = 'mock issue' |
| + |
| + class RpcServer(object): |
| + |
| + def get_description(self, _issue): |
| + return mock['description'] |
| + |
| + def update_description(self, _issue, description): |
| + mock['description'] = description |
| + |
| + |
| +class MockOutputAPI(): |
| + |
| + def PresubmitNotifyResult(self, description): |
| + return description |
| + |
| + |
| +if __name__ == '__main__': |
| + unittest.main() |
| + |