예제 #1
0
 def test_init(self):
     name = Mock()
     description = Mock()
     unit = Mock()
     label_keys = [Mock(), Mock]
     double_gauge = gauge.DoubleGauge(name, description, unit, label_keys)
     self.assertEqual(double_gauge.descriptor.type,
                      metric_descriptor.MetricDescriptorType.GAUGE_DOUBLE)
예제 #2
0
    def test_get_metric(self):
        double_gauge = gauge.DoubleGauge(Mock(), Mock(), Mock(),
                                         [Mock(), Mock])

        timestamp = Mock()

        lv1 = [Mock(), Mock()]
        lv2 = [Mock(), Mock()]
        point1 = double_gauge.get_or_create_time_series(lv1)
        point2 = double_gauge.get_or_create_time_series(lv2)

        point1.set(1.2)
        point2.set(2.2)
        metric = double_gauge.get_metric(timestamp)
        self.assertIsInstance(metric.time_series[0].points[0].value,
                              value_module.ValueDouble)
        self.assertIsInstance(metric.time_series[1].points[0].value,
                              value_module.ValueDouble)
        self.assertEqual(metric.time_series[0].points[0].value.value, 1.2)
        self.assertEqual(metric.time_series[1].points[0].value.value, 2.2)
예제 #3
0
 def test_get_time_series(self):
     double_gauge = gauge.DoubleGauge(Mock(), Mock(), Mock(),
                                      [Mock(), Mock])
     point = double_gauge.get_or_create_time_series([Mock(), Mock()])
     self.assertIsInstance(point, gauge.GaugePointDouble)