Beispiel #1
0
 def testFlattenTrace_ImprovementDirectionCannotBeNone(self):
   """Tests that an improvement_direction must not be None if passed."""
   trace = {
       'type': 'scalar',
       'name': 'bar',
       'units': 'ms',
       'value': 42,
       'improvement_direction': None
   }
   with self.assertRaises(add_point.BadRequestError):
     add_point._FlattenTrace('foo', 'bar', 'summary', trace)
Beispiel #2
0
  def testFlattenTraceRejectsBadImprovementDirection(self):
    """Tests that passing a bad improvement_direction will cause an error."""
    trace = {
        'type': 'scalar',
        'name': 'bar',
        'units': 'ms',
        'value': 42,
        'improvement_direction': 'foo'
    }

    with self.assertRaises(add_point.BadRequestError):
      add_point._FlattenTrace('foo', 'bar', 'summary', trace)
Beispiel #3
0
 def testFlattenTrace_NonSummaryTraceName_SetCorrectly(self):
   """Tests that chart.trace will be flattened to chart/trace."""
   trace = {
       'type': 'scalar',
       'name': 'bar.baz',
       'units': 'ms',
       'value': 42
   }
   row = add_point._FlattenTrace('foo', 'bar', 'baz', trace)
   self.assertEqual(row['test'], 'foo/bar/baz')
Beispiel #4
0
 def testFlattenTrace_CoreTraceName(self):
   """Tests that chartname.summary will be flattened to chartname."""
   trace = {
       'type': 'scalar',
       'name': 'bar',
       'units': 'ms',
       'value': 42
   }
   row = add_point._FlattenTrace('foo', 'bar', 'summary', trace)
   self.assertEqual(row['test'], 'foo/bar')
Beispiel #5
0
 def testFlattenTrace_PreservesUnits(self):
   """Tests that _FlattenTrace preserves the units property."""
   trace = {
       'type': 'scalar',
       'name': 'overall',
       'units': 'ms',
       'value': 42
   }
   row = add_point._FlattenTrace('foo', 'bar', 'bar', trace)
   self.assertEqual(row['units'], 'ms')
Beispiel #6
0
 def testFlattenTrace_RespectsIsRefForDifferentTraceName(self):
   """Tests whether a ref trace that is not a chart has the _ref suffix."""
   trace = {
       'type': 'scalar',
       'name': 'bar.baz',
       'units': 'ms',
       'value': 42
   }
   row = add_point._FlattenTrace(
       'foo', 'bar', 'baz', trace, is_ref=True)
   self.assertEqual(row['test'], 'foo/bar/baz_ref')
Beispiel #7
0
 def testFlattenTraceListValue(self):
   """Tests that lists are properly flattened to avg/stddev."""
   trace = {
       'type': 'list_of_scalar_values',
       'name': 'bar.baz',
       'units': 'ms',
       'values': [5, 10, 25, 10, 15],
   }
   row = add_point._FlattenTrace('foo', 'bar', 'baz', trace)
   self.assertAlmostEqual(row['value'], 13)
   self.assertAlmostEqual(row['error'], 6.78232998)
Beispiel #8
0
 def testFlattenTrace_ScalarValue(self):
   """Tests that scalars are flattened to 0-error values."""
   trace = {
       'type': 'scalar',
       'name': 'overall',
       'units': 'ms',
       'value': 42
   }
   row = add_point._FlattenTrace('foo', 'bar', 'baz', trace)
   self.assertEqual(row['value'], 42)
   self.assertEqual(row['error'], 0)
Beispiel #9
0
  def testFlattenTraceDoesNotAddImprovementDirectionIfAbsent(self):
    """Tests that no higher_is_better is added if no improvement_direction."""
    trace = {
        'type': 'scalar',
        'name': 'bar',
        'units': 'ms',
        'value': 42
    }

    row = add_point._FlattenTrace('foo', 'bar', 'summary', trace)
    self.assertNotIn('higher_is_better', row)
Beispiel #10
0
 def testFlattenTrace_FlattensInteractionRecordLabelToFivePartName(self):
   """Tests whether a TIR label will appear between chart and trace name."""
   trace = {
       'type': 'scalar',
       'name': 'bar',
       'page': 'https://abc.xyz/',
       'units': 'ms',
       'value': 42,
       'tir_label': 'baz'
   }
   row = add_point._FlattenTrace('foo', 'baz@@bar', 'https://abc.xyz/', trace)
   self.assertEqual(row['test'], 'foo/bar/baz/https___abc.xyz_')
Beispiel #11
0
 def testFlattenTrace_SanitizesTraceName(self):
   """Tests whether a trace name with special characters is sanitized."""
   trace = {
       'type': 'scalar',
       'name': 'bar.baz',
       'page': 'http://example.com',
       'units': 'ms',
       'value': 42
   }
   row = add_point._FlattenTrace(
       'foo', 'bar', 'http://example.com', trace)
   self.assertEqual(row['test'], 'foo/bar/http___example.com')
Beispiel #12
0
 def testFlattenTrace_HistogramValue(self):
   """Tests that histograms are yield geommean/stddev as value/error."""
   trace = {
       'type': 'histogram',
       'name': 'bar.baz',
       'units': 'ms',
       'buckets': [{'low': 1, 'high': 5, 'count': 3},
                   {'low': 4, 'high': 6, 'count': 4}]
   }
   row = add_point._FlattenTrace('foo', 'bar', 'baz', trace)
   self.assertAlmostEqual(row['value'], 4.01690877)
   self.assertAlmostEqual(row['error'], 0.99772482)
Beispiel #13
0
 def testFlattenTrace_ListNoneValue(self):
   """Tests that LoS NoneValue is flattened to NaN."""
   trace = {
       'type': 'list_of_scalar_values',
       'name': 'overall',
       'units': 'ms',
       'value': None,
       'none_value_reason': 'Reason for test'
   }
   row = add_point._FlattenTrace('foo', 'bar', 'baz', trace)
   self.assertTrue(math.isnan(row['value']))
   self.assertTrue(math.isnan(row['error']))
Beispiel #14
0
 def testFlattenTraceListValueWithStd(self):
   """Tests that lists with reported std use std as error."""
   trace = {
       'type': 'list_of_scalar_values',
       'name': 'bar.baz',
       'units': 'ms',
       'values': [5, 10, 25, 10, 15],
       'std': 100,
   }
   row = add_point._FlattenTrace('foo', 'bar', 'baz', trace)
   self.assertNotAlmostEqual(row['error'], 6.78232998)
   self.assertEqual(row['error'], 100)
Beispiel #15
0
  def testFlattenTraceAddsImprovementDirectionIfPresent(self):
    """Tests that improvement_direction will be respected if present."""
    trace = {
        'type': 'scalar',
        'name': 'bar',
        'units': 'ms',
        'value': 42,
        'improvement_direction': 'up'
    }

    row = add_point._FlattenTrace('foo', 'bar', 'summary', trace)
    self.assertIn('higher_is_better', row)
    self.assertEqual(row['higher_is_better'], True)