def test_register_exporter(self):
     exporter = mock.Mock()
     execution_context.clear()
     execution_context.set_measure_to_view_map(MeasureToViewMap())
     view_manager = view_manager_module.ViewManager()
     view_manager.register_exporter(exporter)
     count_registered_exporters = len(
         view_manager.measure_to_view_map.exporters)
     self.assertEqual(1, count_registered_exporters)
Beispiel #2
0
    def test_get_and_set(self):
        execution_context.clear()
        execution_context.get_measure_to_view_map()
        self.assertEqual({}, execution_context.get_measure_to_view_map())

        measure_to_view_map = {'key1', 'val1'}
        execution_context.set_measure_to_view_map(measure_to_view_map)

        execution_context.get_measure_to_view_map()
        self.assertEqual(measure_to_view_map,
                         execution_context.get_measure_to_view_map())
    def test_get_all_exported_views(self):
        execution_context.clear()
        execution_context.set_measure_to_view_map(MeasureToViewMap())
        view_manager = view_manager_module.ViewManager()
        exported_views = view_manager.get_all_exported_views()
        self.assertIsNotNone(exported_views)

        view_manager_mock = mock.Mock()
        view_manager = view_manager_mock

        view_manager.get_all_exported_views()
        self.assertTrue(view_manager_mock.get_all_exported_views.called)
    def test_get_view(self):
        view_name = mock.Mock()
        execution_context.clear()
        execution_context.set_measure_to_view_map(MeasureToViewMap())
        view_manager = view_manager_module.ViewManager()
        view_manager.get_view(view_name=view_name)

        view_manager_mock = mock.Mock()
        view_manager = view_manager_mock

        view_manager.get_view(view_name=mock.Mock())
        self.assertTrue(view_manager_mock.get_view.called)
    def test_constructor(self):
        execution_context.clear()
        self.assertEqual({}, execution_context.get_measure_to_view_map())

        view_manager = view_manager_module.ViewManager()

        self.assertIsNotNone(view_manager.time)
        self.assertEqual(view_manager.measure_to_view_map,
                         execution_context.get_measure_to_view_map())

        execution_context.clear()
        measure_to_view_map = {'key1': 'val1'}
        execution_context.set_measure_to_view_map(measure_to_view_map)
        self.assertEqual(measure_to_view_map,
                         execution_context.get_measure_to_view_map())
Beispiel #6
0
    def __init__(self):
        self.time = datetime.utcnow().isoformat() + 'Z'
        if execution_context.get_measure_to_view_map() == {}:
            execution_context.set_measure_to_view_map(MeasureToViewMap())

        self._measure_view_map = execution_context.get_measure_to_view_map()
Beispiel #7
0
    def __init__(self):
        self.time = utils.to_iso_str()
        if execution_context.get_measure_to_view_map() == {}:
            execution_context.set_measure_to_view_map(MeasureToViewMap())

        self._measure_view_map = execution_context.get_measure_to_view_map()
    def __init__(self):
        if execution_context.get_measure_to_view_map() == {}:
            execution_context.set_measure_to_view_map(MeasureToViewMap())

        self.measure_to_view_map = execution_context.get_measure_to_view_map()