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

Side by Side Diff: tools/telemetry/telemetry/value/failure_unittest.py

Issue 439613003: Add Chart JSON processing to Telemetry. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address most of Nat's comments Created 6 years, 4 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 # 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 unittest 7 import unittest
8 import traceback 8 import traceback
9 9
10 from telemetry import value 10 from telemetry import value
(...skipping 17 matching lines...) Expand all
28 raise NotImplementedError() 28 raise NotImplementedError()
29 except Exception: 29 except Exception:
30 v1 = failure.FailureValue(self.pages[0], sys.exc_info()) 30 v1 = failure.FailureValue(self.pages[0], sys.exc_info())
31 self.assertEquals('NotImplementedError', v1.name) 31 self.assertEquals('NotImplementedError', v1.name)
32 32
33 def testBuildbotAndRepresentativeValue(self): 33 def testBuildbotAndRepresentativeValue(self):
34 v = failure.FailureValue.FromMessage(self.pages[0], 'Failure') 34 v = failure.FailureValue.FromMessage(self.pages[0], 'Failure')
35 self.assertIsNone(v.GetBuildbotValue()) 35 self.assertIsNone(v.GetBuildbotValue())
36 self.assertIsNone(v.GetBuildbotDataType( 36 self.assertIsNone(v.GetBuildbotDataType(
37 value.COMPUTED_PER_PAGE_SUMMARY_OUTPUT_CONTEXT)) 37 value.COMPUTED_PER_PAGE_SUMMARY_OUTPUT_CONTEXT))
38 self.assertIsNone(v.GetBuildbotMeasurementAndTraceNameForPerPageResult()) 38 self.assertIsNone(v.GetChartAndTraceNameForPerPageResult())
39 self.assertIsNone(v.GetRepresentativeNumber()) 39 self.assertIsNone(v.GetRepresentativeNumber())
40 self.assertIsNone(v.GetRepresentativeString()) 40 self.assertIsNone(v.GetRepresentativeString())
41 41
42 def testAsDict(self): 42 def testAsDict(self):
43 v = failure.FailureValue.FromMessage(self.pages[0], 'Failure') 43 v = failure.FailureValue.FromMessage(self.pages[0], 'Failure')
44 d = v.AsDictWithoutBaseClassEntries() 44 d = v.AsDictWithoutBaseClassEntries()
45 self.assertTrue(d['value'].find('Exception: Failure') > -1) 45 self.assertTrue(d['value'].find('Exception: Failure') > -1)
46 46
47 def testFromDict(self): 47 def testFromDict(self):
48 try: 48 try:
49 raise Exception('test') 49 raise Exception('test')
50 except Exception: 50 except Exception:
51 exc_info = sys.exc_info() 51 exc_info = sys.exc_info()
52 d = { 52 d = {
53 'type': 'failure', 53 'type': 'failure',
54 'name': exc_info[0].__name__, 54 'name': exc_info[0].__name__,
55 'units': '', 55 'units': '',
56 'value': ''.join(traceback.format_exception(*exc_info)) 56 'value': ''.join(traceback.format_exception(*exc_info))
57 } 57 }
58 v = value.Value.FromDict(d, {}) 58 v = value.Value.FromDict(d, {})
59 59
60 self.assertTrue(isinstance(v, failure.FailureValue)) 60 self.assertTrue(isinstance(v, failure.FailureValue))
61 self.assertEquals(v.name, 'Exception') 61 self.assertEquals(v.name, 'Exception')
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698