Пример #1
0
 def test_should_use_the_latest_end_time_delta_merges(self):
     got = metric_value.merge(MetricKind.DELTA, self.early_ending,
                              self.late_ending)
     expect(got.endTime).to(equal(self.late_ending.endTime))
     got = metric_value.merge(MetricKind.DELTA, self.late_ending,
                              self.early_ending)
     expect(got.endTime).to(equal(self.late_ending.endTime))
Пример #2
0
 def test_should_return_metric_value_with_latest_end_time_for_non_deltas(
         self):
     for kind in (MetricKind.GAUGE, MetricKind.CUMULATIVE):
         got = metric_value.merge(kind, self.early_ending, self.late_ending)
         expect(got).to(equal(self.late_ending))
         got = metric_value.merge(kind, self.late_ending, self.early_ending)
         expect(got).to(equal(self.late_ending))
 def test_should_use_the_latest_end_time_delta_merges(self):
     got = metric_value.merge(MetricKind.DELTA,
                              self.early_ending,
                              self.late_ending)
     expect(got.endTime).to(equal(self.late_ending.endTime))
     got = metric_value.merge(MetricKind.DELTA,
                              self.late_ending,
                              self.early_ending)
     expect(got.endTime).to(equal(self.late_ending.endTime))
Пример #4
0
 def test_should_use_the_earliest_start_time_in_delta_merges(self):
     early_starting = metric_value.create(labels=self.TEST_LABELS,
                                          doubleValue=self.A_FLOAT_VALUE,
                                          startTime=self.EARLY)
     late_starting = metric_value.create(labels=self.TEST_LABELS,
                                         doubleValue=self.A_FLOAT_VALUE,
                                         startTime=self.LATER)
     got = metric_value.merge(MetricKind.DELTA, early_starting,
                              late_starting)
     expect(got.startTime).to(equal(early_starting.startTime))
     got = metric_value.merge(MetricKind.DELTA, late_starting,
                              early_starting)
     expect(got.startTime).to(equal(early_starting.startTime))
 def test_should_use_the_earliest_start_time_in_delta_merges(self):
     early_starting = metric_value.create(
         labels=self.TEST_LABELS,
         doubleValue=self.A_FLOAT_VALUE,
         startTime=self.EARLY)
     late_starting = metric_value.create(
         labels=self.TEST_LABELS,
         doubleValue=self.A_FLOAT_VALUE,
         startTime=self.LATER)
     got = metric_value.merge(MetricKind.DELTA, early_starting,
                              late_starting)
     expect(got.startTime).to(equal(early_starting.startTime))
     got = metric_value.merge(MetricKind.DELTA, late_starting,
                              early_starting)
     expect(got.startTime).to(equal(early_starting.startTime))
Пример #6
0
 def test_should_succeed_for_delta_metrics_with_the_distribution_type(self):
     test_distribution = distribution.create_explicit([0.1, 0.3, 0.5])
     distribution.add_sample(0.4, test_distribution)
     v = metric_value.create(labels=self.TEST_LABELS,
                             distributionValue=test_distribution)
     want = 2 * test_distribution.count
     got = metric_value.merge(MetricKind.DELTA, v, v)
     expect(got.distributionValue.count).to(equal(want))
 def test_should_succeed_for_delta_metrics_with_the_distribution_type(self):
     test_distribution = distribution.create_explicit([0.1, 0.3, 0.5])
     distribution.add_sample(0.4, test_distribution)
     v = metric_value.create(labels=self.TEST_LABELS,
                             distributionValue=test_distribution)
     want = 2 * test_distribution.count
     got = metric_value.merge(MetricKind.DELTA, v, v)
     expect(got.distributionValue.count).to(equal(want))
Пример #8
0
 def test_should_fail_for_delta_metrics_with_unmergable_types(self):
     no_init = metric_value.create()
     unmergeables = [
         metric_value.create(stringValue='a test string'),
         metric_value.create(boolValue=False),
     ]
     for mv in unmergeables:
         testf = lambda: metric_value.merge(MetricKind.DELTA, mv, mv)
         expect(testf).to(raise_error(ValueError))
 def test_should_fail_for_delta_metrics_with_unmergable_types(self):
     no_init = metric_value.create()
     unmergeables = [
         metric_value.create(stringValue='a test string'),
         metric_value.create(boolValue=False),
     ]
     for mv in unmergeables:
         testf = lambda: metric_value.merge(MetricKind.DELTA, mv, mv)
         expect(testf).to(raise_error(ValueError))
Пример #10
0
 def test_should_return_metric_value_with_latest_end_time_for_non_deltas(self):
     for kind in (MetricKind.GAUGE, MetricKind.CUMULATIVE):
         got = metric_value.merge(kind, self.early_ending, self.late_ending)
         expect(got).to(equal(self.late_ending))
         got = metric_value.merge(kind, self.late_ending, self.early_ending)
         expect(got).to(equal(self.late_ending))
Пример #11
0
 def test_should_succeed_for_delta_metrics_with_the_int64_type(self):
     test_int = 4
     v = metric_value.create(labels=self.TEST_LABELS, int64Value=test_int)
     want = 2 * test_int
     got = metric_value.merge(MetricKind.DELTA, v, v)
     expect(got.int64Value).to(equal(want))
Пример #12
0
 def test_should_succeed_for_delta_metrics_with_the_int64_type(self):
     test_int = 4
     v = metric_value.create(labels=self.TEST_LABELS, int64Value=test_int)
     want = 2 * test_int
     got = metric_value.merge(MetricKind.DELTA, v, v)
     expect(got.int64Value).to(equal(want))
Пример #13
0
 def test_should_fail_for_metric_values_with_different_types(self):
     changed = metric_value.create(labels=self.TEST_LABELS, int64Value=1)
     for kind in (MetricKind.GAUGE, MetricKind.CUMULATIVE,
                  MetricKind.DELTA):
         testf = lambda: metric_value.merge(kind, self.test_value, changed)
         expect(testf).to(raise_error(ValueError))
Пример #14
0
 def test_should_succeed_for_delta_metrics_with_the_double_type(self):
     v = self.test_value
     want = 2 * v.doubleValue
     got = metric_value.merge(MetricKind.DELTA, v, v)
     expect(got.doubleValue).to(equal(want))
Пример #15
0
 def test_should_succeed_for_delta_metrics_with_the_money_type(self):
     v = self.test_value_with_money
     want = 2 * v.moneyValue.units
     got = metric_value.merge(MetricKind.DELTA, v, v)
     expect(got.moneyValue.units).to(equal(want))
Пример #16
0
 def test_should_succeed_for_delta_metrics_with_the_double_type(self):
     v = self.test_value
     want = 2 * v.doubleValue
     got = metric_value.merge(MetricKind.DELTA, v, v)
     expect(got.doubleValue).to(equal(want))
Пример #17
0
 def test_should_fail_for_metric_values_with_different_types(self):
     changed = metric_value.create(labels=self.TEST_LABELS, int64Value=1)
     for kind in (MetricKind.GAUGE, MetricKind.CUMULATIVE, MetricKind.DELTA):
         testf = lambda: metric_value.merge(kind, self.test_value, changed)
         expect(testf).to(raise_error(ValueError))
Пример #18
0
 def test_should_fail_for_uninitialized_metric_values(self):
     no_init = metric_value.create()
     for kind in (MetricKind.GAUGE, MetricKind.CUMULATIVE,
                  MetricKind.DELTA):
         testf = lambda: metric_value.merge(kind, no_init, no_init)
         expect(testf).to(raise_error(ValueError))
Пример #19
0
 def test_should_fail_for_uninitialized_metric_values(self):
     no_init = metric_value.create()
     for kind in (MetricKind.GAUGE, MetricKind.CUMULATIVE, MetricKind.DELTA):
         testf = lambda: metric_value.merge(kind, no_init, no_init)
         expect(testf).to(raise_error(ValueError))
Пример #20
0
 def test_should_succeed_for_delta_metrics_with_the_money_type(self):
     v = self.test_value_with_money
     want = 2 * v.moneyValue.units
     got = metric_value.merge(MetricKind.DELTA, v, v)
     expect(got.moneyValue.units).to(equal(want))