OLD | NEW |
1 # Copyright 2014 The Chromium Authors. All rights reserved. | 1 # Copyright 2014 The Chromium Authors. All rights reserved. |
2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
4 | 4 |
5 import os | 5 import os |
6 import sys | 6 import sys |
7 import imp | 7 import imp |
8 import tempfile | 8 import tempfile |
9 import unittest | 9 import unittest |
10 import PRESUBMIT | 10 import PRESUBMIT |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
67 mock_input_api = MockInputApi() | 67 mock_input_api = MockInputApi() |
68 mock_input_api.files = [MockFile('path/test.html', lines)] | 68 mock_input_api.files = [MockFile('path/test.html', lines)] |
69 | 69 |
70 action_xml_path = self._createActionXMLFile() | 70 action_xml_path = self._createActionXMLFile() |
71 return PRESUBMIT.CheckUserActionUpdate(mock_input_api, | 71 return PRESUBMIT.CheckUserActionUpdate(mock_input_api, |
72 MockOutputApi(), | 72 MockOutputApi(), |
73 action_xml_path) | 73 action_xml_path) |
74 | 74 |
75 def _createActionXMLFile(self): | 75 def _createActionXMLFile(self): |
76 content = ('<actions>' | 76 content = ('<actions>' |
77 '<action name="validaction_Disabled">' | 77 '<action name="validaction_Disable">' |
78 ' <owner>Please list the metric\'s owners.</owner>' | 78 ' <owner>Please list the metric\'s owners.</owner>' |
79 ' <description>Enter the description of this user action.</description>' | 79 ' <description>Enter the description of this user action.</description>' |
80 '</action>' | 80 '</action>' |
81 '<action name="validaction_Enabled">' | 81 '<action name="validaction_Enable">' |
82 ' <owner>Please list the metric\'s owners. </owner>' | 82 ' <owner>Please list the metric\'s owners. </owner>' |
83 ' <description>Enter the description of this user action.</description>' | 83 ' <description>Enter the description of this user action.</description>' |
84 '</action>' | 84 '</action>' |
85 '<action name="notboolean_validaction">' | 85 '<action name="notboolean_validaction">' |
86 ' <owner>Please list the metric\'s owners.</owner>' | 86 ' <owner>Please list the metric\'s owners.</owner>' |
87 ' <description>Enter the description of this user action.</description>' | 87 ' <description>Enter the description of this user action.</description>' |
88 '</action>' | 88 '</action>' |
89 '</actions>') | 89 '</actions>') |
90 sys_temp = tempfile.gettempdir() | 90 sys_temp = tempfile.gettempdir() |
91 action_xml_path = os.path.join(sys_temp, 'actions_test.xml') | 91 action_xml_path = os.path.join(sys_temp, 'actions_test.xml') |
92 if not os.path.exists(action_xml_path): | 92 if not os.path.exists(action_xml_path): |
93 with open(action_xml_path, 'w+') as action_file: | 93 with open(action_xml_path, 'w+') as action_file: |
94 action_file.write(content) | 94 action_file.write(content) |
95 | 95 |
96 return action_xml_path | 96 return action_xml_path |
97 | 97 |
98 | 98 |
99 if __name__ == '__main__': | 99 if __name__ == '__main__': |
100 unittest.main() | 100 unittest.main() |
OLD | NEW |