OLD | NEW |
1 # Copyright 2016 The Chromium Authors. All rights reserved. | 1 # Copyright 2016 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 unittest | 5 import unittest |
6 import os | 6 import os |
7 | 7 |
8 from perf_insights import function_handle | 8 from perf_insights import function_handle |
9 from perf_insights.mre import failure | 9 from perf_insights.mre import failure |
10 from perf_insights.mre import job as job_module | 10 from perf_insights.mre import job as job_module |
(...skipping 28 matching lines...) Expand all Loading... |
39 story_set = story.StorySet(base_dir=os.path.dirname(__file__)) | 39 story_set = story.StorySet(base_dir=os.path.dirname(__file__)) |
40 p = page.Page('http://www.foo.com/', story_set, story_set.base_dir) | 40 p = page.Page('http://www.foo.com/', story_set, story_set.base_dir) |
41 | 41 |
42 scalar_value = { | 42 scalar_value = { |
43 'type': 'numeric', | 43 'type': 'numeric', |
44 'numeric': { | 44 'numeric': { |
45 'type': 'scalar', | 45 'type': 'scalar', |
46 'unit': 'timeInMs_smallerIsBetter', | 46 'unit': 'timeInMs_smallerIsBetter', |
47 'value': 42 | 47 'value': 42 |
48 }, | 48 }, |
49 'grouping_keys': { | 49 'name': 'foo', |
50 'name': 'foo' | |
51 }, | |
52 'options': { | 50 'options': { |
53 'description': 'desc' | 51 'description': 'desc' |
54 } | 52 } |
55 } | 53 } |
56 | 54 |
57 v = common_value_helpers.TranslateScalarValue(scalar_value, p) | 55 v = common_value_helpers.TranslateScalarValue(scalar_value, p) |
58 | 56 |
59 self.assertIsInstance(v, scalar.ScalarValue) | 57 self.assertIsInstance(v, scalar.ScalarValue) |
60 self.assertEquals('foo', v.name) | 58 self.assertEquals('foo', v.name) |
61 self.assertEquals(p, v.page) | 59 self.assertEquals(p, v.page) |
62 self.assertEquals('timeInMs', v.units) | 60 self.assertEquals('timeInMs', v.units) |
63 self.assertEquals(42, v.value) | 61 self.assertEquals(42, v.value) |
64 self.assertEquals(improvement_direction.DOWN, v.improvement_direction) | 62 self.assertEquals(improvement_direction.DOWN, v.improvement_direction) |
65 self.assertEquals('desc', v.description) | 63 self.assertEquals('desc', v.description) |
66 | 64 |
67 def testTranslateScalarNoneValue(self): | 65 def testTranslateScalarNoneValue(self): |
68 story_set = story.StorySet(base_dir=os.path.dirname(__file__)) | 66 story_set = story.StorySet(base_dir=os.path.dirname(__file__)) |
69 p = page.Page('http://www.foo.com/', story_set, story_set.base_dir) | 67 p = page.Page('http://www.foo.com/', story_set, story_set.base_dir) |
70 | 68 |
71 scalar_value = { | 69 scalar_value = { |
72 'type': 'numeric', | 70 'type': 'numeric', |
73 'numeric': { | 71 'numeric': { |
74 'type': 'scalar', | 72 'type': 'scalar', |
75 'unit': 'timeInMs_smallerIsBetter', | 73 'unit': 'timeInMs_smallerIsBetter', |
76 'value': None | 74 'value': None |
77 }, | 75 }, |
78 'grouping_keys': { | 76 'name': 'foo' |
79 'name': 'foo' | |
80 } | |
81 } | 77 } |
82 | 78 |
83 v = common_value_helpers.TranslateScalarValue(scalar_value, p) | 79 v = common_value_helpers.TranslateScalarValue(scalar_value, p) |
84 | 80 |
85 self.assertIsNone(v.value) | 81 self.assertIsNone(v.value) |
86 self.assertEquals('Common scalar contained None', v.none_value_reason) | 82 self.assertEquals('Common scalar contained None', v.none_value_reason) |
OLD | NEW |