def testChangePoint_CanBeMadeAndConvertedToDict(self): series = list(enumerate([4, 4, 4, 8, 8, 8, 8])) change_point = find_change_points.MakeChangePoint(series, 3) self.assertEqual( find_change_points.ChangePoint(x_value=3, median_before=4.0, median_after=8.0, size_before=3, size_after=4, window_start=0, window_end=6, relative_change=1.0, std_dev_before=0.0, t_statistic=float('inf'), degrees_of_freedom=1.0, p_value=0.001), change_point) self.assertEqual( { 'x_value': 3, 'median_before': 4.0, 'median_after': 8.0, 'size_before': 3, 'size_after': 4, 'window_start': 0, 'window_end': 6, 'relative_change': 1.0, 'std_dev_before': 0.0, 't_statistic': float('inf'), 'degrees_of_freedom': 1.0, 'p_value': 0.001, }, change_point.AsDict())
def testRemoveKnownAnomalies_SomePriorAnomalies_ReturnsFilteredList(self): test = self._MakeSampleTest() test.last_alerted_revision = 3 series = [(i, i) for i in range(0, 6)] change_points = [find_change_points.MakeChangePoint(series, i) for i in [2, 3, 4]] filtered = find_change_points_exp._RemoveKnownAnomalies(test, change_points) # Only entries for after the last_alerted_revision are kept. self.assertEqual(change_points[2:], filtered) # The last_alerted_revision property of the TestMetadata is updated. self.assertEqual(4, test.last_alerted_revision) # The TestMetadata entity is never put(). self.assertIsNone(test.key.get())