def test_good_data_only(self): """Test trimming a list of samples with only good data""" samples = [ self._make_sample(five_hours_ago), self._make_sample(four_hours_ago), self._make_sample(now) ] data.trim(samples) self.assertEquals(len(samples), 3)
def test_bad_data_only_within_threshold(self): """ Test trimming list of samples with only bad data that does NOT exceed the threshold. """ samples = [ self._make_sample(now, 'build') ] data.trim(samples) self.assertEquals(len(samples), 1)
def test_bad_data_only_exceeds_threshold(self): """ Test trimming list of samples with only bad data that exceeds threshold. """ samples = [ self._make_sample(five_hours_ago, 'build'), self._make_sample(four_hours_ago, 'build'), self._make_sample(now, 'build') ] data.trim(samples) self.assertEquals(len(samples), 0)
def test_mixed_within_threshold(self): """ Test trimming list of samples with good and bad that does not exceed threshold. """ samples = [ self._make_sample(five_hours_ago), self._make_sample(four_hours_ago), self._make_sample(two_hours_ago, 'build'), self._make_sample(one_hour_ago, 'build'), self._make_sample(now, 'build') ] data.trim(samples) self.assertEquals(len(samples), 5)
def test_mixed_exceeds_threshold(self): """ Test trimming list of samples with good and bad that exceeds threshold. """ samples = [ self._make_sample(five_hours_ago), self._make_sample(four_hours_ago), self._make_sample(three_hours_ago, 'build'), self._make_sample(one_hour_ago, 'build'), self._make_sample(now, 'build') ] data.trim(samples) self.assertEquals(len(samples), 2) for s in samples: self.assertEquals(s.resource_metadata.get('status'), 'good')
def test_empty(self): """Test trimming an empty list of samples.""" samples = [] data.trim(samples)