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'))
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'))
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'))
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.')
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'))