| 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 59f7dff9a0747fb6f88392fd5f59e271ba8130ab..2976dacd96084b6694501039d894b505f6a2f38f 100644
|
| --- a/tools/telemetry/telemetry/value/value_unittest.py
|
| +++ b/tools/telemetry/telemetry/value/value_unittest.py
|
| @@ -15,6 +15,8 @@ class TestBase(unittest.TestCase):
|
| self.page_set.AddPageWithDefaultRunNavigate("http://www.baz.com/")
|
| self.page_set.AddPageWithDefaultRunNavigate("http://www.foo.com/")
|
|
|
| + self.paths = ['trace.html', 'foo.txt']
|
| +
|
| @property
|
| def pages(self):
|
| return self.page_set.pages
|
| @@ -50,11 +52,21 @@ class ValueForTest(value.Value):
|
| pass
|
|
|
| class ValueForAsDictTest(ValueForTest):
|
| + def __init__(self, page, name, units, important=False, description=None,
|
| + paths=None):
|
| + super(ValueForAsDictTest, self).__init__(page, name, units, important,
|
| + description, paths)
|
| +
|
| @staticmethod
|
| def GetJSONTypeName():
|
| return 'baz'
|
|
|
| class ValueForFromDictTest(ValueForTest):
|
| + def __init__(self, page, name, units, important=False, description=None,
|
| + paths=None):
|
| + super(ValueForFromDictTest, self).__init__(page, name, units, important,
|
| + description, paths)
|
| +
|
| @staticmethod
|
| def FromDict(value_dict, page_dict):
|
| kwargs = value.Value.GetConstructorKwArgs(value_dict, page_dict)
|
| @@ -69,31 +81,42 @@ class ValueTest(TestBase):
|
| page0 = self.pages[0]
|
| page1 = self.pages[0]
|
|
|
| - a = value.Value(page0, 'x', 'unit', important=False, description=None)
|
| - b = value.Value(page1, 'x', 'unit', important=False, description=None)
|
| + a = value.Value(page0, 'x', 'unit', important=False, description=None,
|
| + paths=[])
|
| + b = value.Value(page1, 'x', 'unit', important=False, description=None,
|
| + paths=[])
|
| +
|
| self.assertTrue(b.IsMergableWith(a))
|
|
|
| def testIncompat(self):
|
| page0 = self.pages[0]
|
|
|
| - a = value.Value(page0, 'x', 'unit', important=False, description=None)
|
| + a = value.Value(page0, 'x', 'unit', important=False, description=None,
|
| + paths=[])
|
| b = value.Value(page0, 'x', 'incompatUnit', important=False,
|
| - description=None)
|
| + description=None, paths=[])
|
| +
|
| self.assertFalse(b.IsMergableWith(a))
|
|
|
| - a = value.Value(page0, 'x', 'unit', important=False, description=None)
|
| - b = value.Value(page0, 'x', 'unit', important=True, description=None)
|
| + a = value.Value(page0, 'x', 'unit', important=False, description=None,
|
| + paths=[])
|
| + b = value.Value(page0, 'x', 'unit', important=True, description=None,
|
| + paths=[])
|
| +
|
| self.assertFalse(b.IsMergableWith(a))
|
|
|
| - a = value.Value(page0, 'x', 'unit', important=False, description=None)
|
| - b = ValueForTest(page0, 'x', 'unit', important=True, description=None)
|
| + a = value.Value(page0, 'x', 'unit', important=False, description=None,
|
| + paths=[])
|
| + b = ValueForTest(page0, 'x', 'unit', important=True, description=None,
|
| + paths=[])
|
| +
|
| self.assertFalse(b.IsMergableWith(a))
|
|
|
| def testAsDictBaseKeys(self):
|
| - v = ValueForAsDictTest(None, 'x', 'unit', important=True, description=None)
|
| + v = ValueForAsDictTest(None, 'x', 'unit')
|
| d = v.AsDict()
|
|
|
| - self.assertEquals(d, {
|
| + self.assertEqual(d, {
|
| 'name': 'x',
|
| 'type': 'baz',
|
| 'units': 'unit',
|
| @@ -102,28 +125,41 @@ class ValueTest(TestBase):
|
| def testAsDictWithPage(self):
|
| page0 = self.pages[0]
|
|
|
| - v = ValueForAsDictTest(page0, 'x', 'unit', important=False,
|
| - description=None)
|
| + v = ValueForAsDictTest(page0, 'x', 'unit')
|
| d = v.AsDict()
|
|
|
| self.assertIn('page_id', d)
|
|
|
| def testAsDictWithoutPage(self):
|
| - v = ValueForAsDictTest(None, 'x', 'unit', important=False, description=None)
|
| + v = ValueForAsDictTest(None, 'x', 'unit')
|
| d = v.AsDict()
|
|
|
| self.assertNotIn('page_id', d)
|
|
|
| def testAsDictWithDescription(self):
|
| - v = ValueForAsDictTest(None, 'x', 'unit', important=False,
|
| - description='Some description.')
|
| + v = ValueForAsDictTest(None, 'x', 'unit', description='Some description.')
|
| d = v.AsDict()
|
| +
|
| self.assertEqual('Some description.', d['description'])
|
|
|
| def testAsDictWithoutDescription(self):
|
| - v = ValueForAsDictTest(None, 'x', 'unit', important=False, description=None)
|
| + v = ValueForAsDictTest(None, 'x', 'unit')
|
| +
|
| self.assertNotIn('description', v.AsDict())
|
|
|
| + def testAsDictWithFile(self):
|
| + file0 = self.paths[0]
|
| + v = ValueForAsDictTest(None, 'x', 'unit', paths=[file0])
|
| + d = v.AsDict()
|
| +
|
| + self.assertEqual(d['paths'][0], 'trace.html')
|
| +
|
| + def testAsDictWithoutFile(self):
|
| + v = ValueForAsDictTest(None, 'x', 'unit')
|
| + d = v.AsDict()
|
| +
|
| + self.assertNotIn('paths', d)
|
| +
|
| def testFromDictBaseKeys(self):
|
| d = {
|
| 'type': 'value_for_from_dict_test',
|
| @@ -132,9 +168,10 @@ class ValueTest(TestBase):
|
| }
|
|
|
| v = value.Value.FromDict(d, None)
|
| - self.assertEquals(v.name, 'x')
|
| +
|
| + self.assertEqual(v.name, 'x')
|
| self.assertTrue(isinstance(v, ValueForFromDictTest))
|
| - self.assertEquals(v.units, 'unit')
|
| + self.assertEqual(v.units, 'unit')
|
|
|
| def testFromDictWithPage(self):
|
| page0 = self.pages[0]
|
| @@ -149,7 +186,7 @@ class ValueTest(TestBase):
|
|
|
| v = value.Value.FromDict(d, page_dict)
|
|
|
| - self.assertEquals(v.page.id, page0.id)
|
| + self.assertEqual(v.page.id, page0.id)
|
|
|
| def testFromDictWithoutPage(self):
|
| d = {
|
| @@ -160,7 +197,7 @@ class ValueTest(TestBase):
|
|
|
| v = value.Value.FromDict(d, {})
|
|
|
| - self.assertEquals(v.page, None)
|
| + self.assertEqual(v.page, None)
|
|
|
| def testFromDictWithDescription(self):
|
| d = {
|
| @@ -171,7 +208,8 @@ class ValueTest(TestBase):
|
| }
|
|
|
| v = value.Value.FromDict(d, {})
|
| - self.assertEquals(v.description, 'foo')
|
| +
|
| + self.assertEqual(v.description, 'foo')
|
|
|
| def testFromDictWithoutDescription(self):
|
| d = {
|
| @@ -181,7 +219,8 @@ class ValueTest(TestBase):
|
| }
|
|
|
| v = value.Value.FromDict(d, {})
|
| - self.assertEquals(v.description, None)
|
| +
|
| + self.assertEqual(v.description, None)
|
|
|
| def testListOfValuesFromListOfDicts(self):
|
| d0 = {
|
| @@ -195,5 +234,6 @@ class ValueTest(TestBase):
|
| 'units': 'unit'
|
| }
|
| vs = value.Value.ListOfValuesFromListOfDicts([d0, d1], {})
|
| - self.assertEquals(vs[0].name, 'x')
|
| - self.assertEquals(vs[1].name, 'y')
|
| +
|
| + self.assertEqual(vs[0].name, 'x')
|
| + self.assertEqual(vs[1].name, 'y')
|
|
|