예제 #1
0
 def testUpdateFromJson_ExistingUnit_ChangesDirection(self):
   units_to_direction.UpdateFromJson({
       'ms': {'improvement_direction': 'down'},
   })
   self.assertEqual(
       anomaly.DOWN, units_to_direction.GetImprovementDirection('ms'))
   units_to_direction.UpdateFromJson({
       'ms': {'improvement_direction': 'up'},
   })
   self.assertEqual(
       anomaly.UP, units_to_direction.GetImprovementDirection('ms'))
예제 #2
0
 def testUpdateFromJson_UnknownUnit_Added(self):
   units_to_direction.UpdateFromJson({
       'ms': {'improvement_direction': 'down'},
   })
   self.assertEqual(
       anomaly.UNKNOWN, units_to_direction.GetImprovementDirection('runs/s'))
   units_to_direction.UpdateFromJson({
       'ms': {'improvement_direction': 'down'},
       'runs/s': {'improvement_direction': 'up'},
   })
   self.assertEqual(
       anomaly.UP, units_to_direction.GetImprovementDirection('runs/s'))
예제 #3
0
 def testUpdateFromJson_ExistingUnitNotInNewList_RemovesUnit(self):
   units_to_direction.UpdateFromJson({
       'ms': {'improvement_direction': 'down'},
       'score': {'improvement_direction': 'up'},
   })
   self.assertEqual(
       anomaly.UP, units_to_direction.GetImprovementDirection('score'))
   units_to_direction.UpdateFromJson({
       'ms': {'improvement_direction': 'down'},
   })
   self.assertEqual(
       anomaly.UNKNOWN, units_to_direction.GetImprovementDirection('score'))
예제 #4
0
    def post(self):
        """Updates the test metadata.

    Outputs:
      Nothing if successful, an error message if there was an error.
    """
        units_data = _GetAndParseChromiumJsonFile(_UNIT_JSON_PATH)
        if units_data:
            units_to_direction.UpdateFromJson(units_data)
        else:
            self.ReportError('Could not fetch or parse unit data.')
예제 #5
0
 def testUpdateFromJson_SetsImprovementDirections(self):
   units_to_direction.UpdateFromJson({
       'description': 'this is ignored',
       'ms': {'improvement_direction': 'down'},
       'score': {'improvement_direction': 'up'},
   })
   self.assertEqual(
       anomaly.DOWN, units_to_direction.GetImprovementDirection('ms'))
   self.assertEqual(
       anomaly.UP, units_to_direction.GetImprovementDirection('score'))
   self.assertEqual(
       anomaly.UNKNOWN,
       units_to_direction.GetImprovementDirection('does-not-exist'))