示例#1
0
 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)
示例#2
0
 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)
示例#3
0
 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)
示例#4
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)
示例#5
0
 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')
示例#6
0
 def test_empty(self):
     """Test trimming an empty list of samples."""
     samples = []
     data.trim(samples)