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

Unified Diff: third_party/WebKit/LayoutTests/imported/PRESUBMIT_test.py

Issue 2512563002: Add WPTEXPORT footer automatically in DepsUpdater and imported/PRESUBMIT (Closed)
Patch Set: Created 4 years, 1 month 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
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()
+

Powered by Google App Engine
This is Rietveld 408576698