Пример #1
0
    def test_register_view(self):
        """ "
        `MeterProvider` provides a way to configure `View`s.
        """

        meter_provider = MeterProvider()

        self.assertTrue(hasattr(meter_provider, "register_view"))

        view = View()

        meter_provider.register_view(view)

        self.assertTrue(meter_provider._views, [view])
Пример #2
0
    def test_meter_configuration(self):
        """
        Any updated configuration is applied to all returned `Meter`s.
        """

        meter_provider = MeterProvider()

        view_0 = View()

        meter_provider.register_view(view_0)

        meter_0 = meter_provider.get_meter("meter_0")
        meter_1 = meter_provider.get_meter("meter_1")

        self.assertEqual(meter_0._meter_provider._views, [view_0])
        self.assertEqual(meter_1._meter_provider._views, [view_0])

        view_1 = View()

        meter_provider.register_view(view_1)

        self.assertEqual(meter_0._meter_provider._views, [view_0, view_1])
        self.assertEqual(meter_1._meter_provider._views, [view_0, view_1])