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

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

Issue 381723002: Refactor Telemetry value system to support AsDict() (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address Nat's Comments Created 6 years, 5 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
« no previous file with comments | « tools/telemetry/telemetry/value/string_unittest.py ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/telemetry/telemetry/value/value_unittest.py
diff --git a/tools/telemetry/telemetry/value/value_unittest.py b/tools/telemetry/telemetry/value/value_unittest.py
index 395227e73b78f2cb67c613b2bec1afe8e52448d2..15b568cb10899044918f5a7fdd3d0eceb0bbbc3c 100644
--- a/tools/telemetry/telemetry/value/value_unittest.py
+++ b/tools/telemetry/telemetry/value/value_unittest.py
@@ -18,10 +18,11 @@ class TestBase(unittest.TestCase):
def pages(self):
return self.page_set.pages
-class ValueForMergingTest(value.Value):
+class ValueForTest(value.Value):
@classmethod
def MergeLikeValuesFromSamePage(cls, values):
pass
+
@classmethod
def MergeLikeValuesFromDifferentPages(cls, values,
group_by_name_suffix=False):
@@ -43,6 +44,15 @@ class ValueForMergingTest(value.Value):
def GetRepresentativeString(self):
pass
+ @classmethod
+ def GetJSONTypeName(cls):
+ pass
+
+class ValueForAsDictTest(ValueForTest):
+ @classmethod
+ def GetJSONTypeName(cls):
+ return 'baz'
+
class ValueTest(TestBase):
def testCompat(self):
page0 = self.pages[0]
@@ -64,5 +74,30 @@ class ValueTest(TestBase):
self.assertFalse(b.IsMergableWith(a))
a = value.Value(page0, 'x', 'unit', important=False)
- b = ValueForMergingTest(page0, 'x', 'unit', important=True)
+ b = ValueForTest(page0, 'x', 'unit', important=True)
self.assertFalse(b.IsMergableWith(a))
+
+ def testAsDictBaseKeys(self):
+ v = ValueForAsDictTest(None, 'x', 'unit', important=True)
+ d = v.AsDict()
+
+ self.assertEquals(d, {
+ 'name': 'x',
+ 'type': 'baz',
+ 'unit': 'unit',
+ })
+
+ def testAsDictWithPage(self):
+ page0 = self.pages[0]
+
+ v = ValueForAsDictTest(page0, 'x', 'unit', important=False)
+ d = v.AsDict()
+
+ self.assertIn('page_id', d)
+
+
+ def testAsDictWithoutPage(self):
+ v = ValueForAsDictTest(None, 'x', 'unit', important=False)
+ d = v.AsDict()
+
+ self.assertNotIn('page_id', d)
« no previous file with comments | « tools/telemetry/telemetry/value/string_unittest.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698