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

Unified Diff: tools/telemetry/telemetry/value/histogram_util_unittest.py

Issue 941803002: Work around exceptions when the 'high' value for a histogram is not present. This happens when the … (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Added method in histogram_util to parse histogram buckets and correctly set 'high' value Created 5 years, 10 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 side-by-side diff with in-line comments
Download patch
Index: tools/telemetry/telemetry/value/histogram_util_unittest.py
diff --git a/tools/telemetry/telemetry/value/histogram_util_unittest.py b/tools/telemetry/telemetry/value/histogram_util_unittest.py
index a91d0f9f21bf4ce46adf5dc9ef04a33ddbd09ed3..d20cacafb510334902e2abc3bc307148827989d7 100644
--- a/tools/telemetry/telemetry/value/histogram_util_unittest.py
+++ b/tools/telemetry/telemetry/value/histogram_util_unittest.py
@@ -50,3 +50,31 @@ class TestHistogram(unittest.TestCase):
self.assertEquals(5, new_buckets[1])
self.assertEquals(12, new_buckets[2])
self.assertEquals(21, new_buckets[3])
+
+
+ def testGetHistogramBucketsFromRawValue_Max(self):
+ raw_value = {'buckets': [
+ {'count': 4, 'low': 10, 'high': 15,},
+ {'count': 6, 'low': 16, 'high': 18,},
+ {'count': 8, 'low': 19},
+ ]}
+ buckets = histogram_util.GetHistogramBucketsFromRawValue(raw_value)
+ self.assertEquals([
+ {'count': 4, 'low': 10, 'high': 15,},
+ {'count': 6, 'low': 16, 'high': 18,},
+ {'count': 8, 'low': 19, 'high': 19},],
+ buckets)
+
+
+ def testGetHistogramBucketsFromJson(self):
+ json_value = json.dumps({'buckets': [
+ {'count': 4, 'low': 10, 'high': 15,},
+ {'count': 6, 'low': 16, 'high': 18,},
+ {'count': 8, 'low': 19, 'high': 25},
+ ]})
+ buckets = histogram_util.GetHistogramBucketsFromJson(json_value)
+ self.assertEquals([
+ {'count': 4, 'low': 10, 'high': 15,},
+ {'count': 6, 'low': 16, 'high': 18,},
+ {'count': 8, 'low': 19, 'high': 25},],
+ buckets)

Powered by Google App Engine
This is Rietveld 408576698