예제 #1
0
    def test_it_raises_an_error_when_count_isnt_a_positive_integer(self):
        with self.assertRaises(ValueError):
            exponential_buckets(start=100, factor=2, count=0)

        with self.assertRaises(ValueError):
            exponential_buckets(start=100, factor=2, count=-1)
예제 #2
0
 def test_it_generates_an_exponential_series(self):
     buckets = exponential_buckets(start=100.0, factor=2, count=5)
     self.assertEqual(
         buckets, [100.0, 200.0, 400.0, 800.0, 1600.0, INFINITY]
     )
예제 #3
0
 def test_it_raises_an_error_when_factor_le_1(self):
     for factor in [1, 0, -1]:
         with self.assertRaises(ValueError):
             exponential_buckets(start=100, factor=factor, count=10)
예제 #4
0
 def test_generated_buckets_length(self):
     count = 5
     buckets = exponential_buckets(start=100.0, factor=2, count=count)
     self.assertEqual(len(buckets), count + 1)
예제 #5
0
 def test_it_raises_an_error_when_start_is_negative(self):
     with self.assertRaises(ValueError):
         exponential_buckets(start=-10, factor=2, count=100)