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

Side by Side Diff: scripts/slave/unittests/runtest_test.py

Issue 2346963003: Updating perf recipe for disabled chartjson data. (Closed)
Patch Set: Created 4 years, 3 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 unified diff | Download patch
OLDNEW
1 #!/usr/bin/env python 1 #!/usr/bin/env python
2 # Copyright 2014 The Chromium Authors. All rights reserved. 2 # Copyright 2014 The Chromium Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be 3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file. 4 # found in the LICENSE file.
5 5
6 """Unit tests for functions in runtest.py.""" 6 """Unit tests for functions in runtest.py."""
7 7
8 import unittest 8 import unittest
9 9
10 import test_env # pylint: disable=W0403,W0611 10 import test_env # pylint: disable=W0403,W0611
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
124 # Also, this test method doesn't reference self. 124 # Also, this test method doesn't reference self.
125 # pylint: disable=W0212,R0201 125 # pylint: disable=W0212,R0201
126 @mock.patch('slave.runtest._GetDataFromLogProcessor') 126 @mock.patch('slave.runtest._GetDataFromLogProcessor')
127 @mock.patch('slave.results_dashboard.MakeListOfPoints') 127 @mock.patch('slave.results_dashboard.MakeListOfPoints')
128 @mock.patch('slave.results_dashboard.SendResults') 128 @mock.patch('slave.results_dashboard.SendResults')
129 def test_SendResultsToDashboard_SimpleCase( 129 def test_SendResultsToDashboard_SimpleCase(
130 self, SendResults, MakeListOfPoints, GetDataFromLogProcessor): 130 self, SendResults, MakeListOfPoints, GetDataFromLogProcessor):
131 """Tests that the right methods get called in _SendResultsToDashboard.""" 131 """Tests that the right methods get called in _SendResultsToDashboard."""
132 # Since this method just tests that certain methods get called when 132 # Since this method just tests that certain methods get called when
133 # a call to _SendResultsDashboard is made, the data used below is arbitrary. 133 # a call to _SendResultsDashboard is made, the data used below is arbitrary.
134 fake_charts_data = {'chart': {'traces': {'x': [1, 0]}, 'rev': 1000}} 134 fake_charts_data = \
135 {'chart': {'traces': {'x': [1, 0]}, 'rev': 1000}}
perezju 2016/09/22 08:50:27 why this change?
eyaich1 2016/09/26 15:22:11 Not sure. Done.
135 fake_points_data = [{'test': 'master/bot/chart/x', 'revision': 1000}] 136 fake_points_data = [{'test': 'master/bot/chart/x', 'revision': 1000}]
136 fake_results_tracker = mock.Mock() 137 fake_results_tracker = mock.Mock()
137 fake_results_tracker.IsChartJson = mock.MagicMock(return_value=False) 138 fake_results_tracker.IsChartJson = mock.MagicMock(return_value=False)
138 GetDataFromLogProcessor.return_value = fake_charts_data 139 GetDataFromLogProcessor.return_value = fake_charts_data
139 MakeListOfPoints.return_value = fake_points_data 140 MakeListOfPoints.return_value = fake_points_data
140 141
141 result = runtest._SendResultsToDashboard( 142 result = runtest._SendResultsToDashboard(
142 fake_results_tracker, { 143 fake_results_tracker, {
143 'system': 'linux', 144 'system': 'linux',
144 'test': 'sunspider', 145 'test': 'sunspider',
(...skipping 14 matching lines...) Expand all
159 # Then a function is called to send the data (and any cached data). 160 # Then a function is called to send the data (and any cached data).
160 SendResults.assert_called_with( 161 SendResults.assert_called_with(
161 fake_points_data, 'http://x.com', 'builddir') 162 fake_points_data, 'http://x.com', 'builddir')
162 163
163 # No errors, should return True. 164 # No errors, should return True.
164 self.assertTrue(result) 165 self.assertTrue(result)
165 166
166 @mock.patch('slave.results_dashboard.MakeDashboardJsonV1') 167 @mock.patch('slave.results_dashboard.MakeDashboardJsonV1')
167 @mock.patch('slave.results_dashboard.SendResults') 168 @mock.patch('slave.results_dashboard.SendResults')
168 def test_SendResultsToDashboard_Telemetry( 169 def test_SendResultsToDashboard_Telemetry(
169 self, SendResults, MakeDashboardJsonV1): 170 self, SendResults, MakeDashboardJsonV1):
perezju 2016/09/22 08:50:27 Also add a test case showing that data is not sent
eyaich1 2016/09/26 15:22:11 Done.
170 """Tests that the right methods get called in _SendResultsToDashboard.""" 171 """Tests that the right methods get called in _SendResultsToDashboard."""
171 # Since this method just tests that certain methods get called when 172 # Since this method just tests that certain methods get called when
172 # a call to _SendResultsDashboard is made, the data used below is arbitrary. 173 # a call to _SendResultsDashboard is made, the data used below is arbitrary.
173 fake_json_data = {'chart': {'traces': {'x': [1, 0]}, 'rev': 1000}} 174 fake_json_data = \
175 {'chart': {'traces': {'x': [1, 0]}, 'rev': 1000}, 'disabled': False}
perezju 2016/09/22 08:50:27 The style guide discourages the use of backslash f
eyaich1 2016/09/26 15:22:11 Done.
174 fake_results_tracker = mock.Mock() 176 fake_results_tracker = mock.Mock()
175 fake_results_tracker.IsChartJson = mock.MagicMock(return_value=True) 177 fake_results_tracker.IsChartJson = mock.MagicMock(return_value=True)
176 fake_results_tracker.ChartJson = mock.MagicMock(return_value=fake_json_data) 178 fake_results_tracker.ChartJson = mock.MagicMock(return_value=fake_json_data)
177 fake_results_tracker.IsReferenceBuild = mock.MagicMock(return_value=False) 179 fake_results_tracker.IsReferenceBuild = mock.MagicMock(return_value=False)
178 fake_results_tracker.Cleanup = mock.MagicMock() 180 fake_results_tracker.Cleanup = mock.MagicMock()
179 MakeDashboardJsonV1.return_value = {'doesnt': 'matter'} 181 MakeDashboardJsonV1.return_value = (False, {'doesnt': 'matter'})
180 182
181 result = runtest._SendResultsToDashboard( 183 result = runtest._SendResultsToDashboard(
182 fake_results_tracker, { 184 fake_results_tracker, {
183 'system': 'linux', 185 'system': 'linux',
184 'test': 'sunspider', 186 'test': 'sunspider',
185 'url': 'http://x.com', 187 'url': 'http://x.com',
186 'build_dir': 'builddir', 188 'build_dir': 'builddir',
187 'mastername': 'my.master', 189 'mastername': 'my.master',
188 'buildername': 'Builder', 190 'buildername': 'Builder',
189 'buildnumber': 123, 191 'buildnumber': 123,
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
243 'git_revision': '9a7b354', 245 'git_revision': '9a7b354',
244 } 246 }
245 versions = runtest._GetTelemetryRevisions(options) 247 versions = runtest._GetTelemetryRevisions(options)
246 self.assertEqual( 248 self.assertEqual(
247 {'rev': '294850', 'webkit_rev': '34f9d01', 'git_revision': '9a7b354', 249 {'rev': '294850', 'webkit_rev': '34f9d01', 'git_revision': '9a7b354',
248 'point_id': 1470050195}, 250 'point_id': 1470050195},
249 versions) 251 versions)
250 252
251 if __name__ == '__main__': 253 if __name__ == '__main__':
252 unittest.main() 254 unittest.main()
OLDNEW
« scripts/slave/runtest.py ('K') | « scripts/slave/unittests/results_dashboard_test.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698