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)
    def test_get_all_exported_views(self):
        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()
        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_register_view(self):
        view = mock.Mock()
        view_manager = view_manager_module.ViewManager()
        view_manager.register_view(view=view)

        view_manager_mock = mock.Mock()
        view_manager = view_manager_mock

        view_manager.register_view(view=mock.Mock())
        self.assertTrue(view_manager_mock.register_view.called)
    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())
    def test_constructor(self):
        view_manager = view_manager_module.ViewManager()

        self.assertIsNotNone(view_manager.time)
        self.assertIsNotNone(view_manager.measure_to_view_map)