Beispiel #1
0
    def test_row_fitting(self):
        widgets = DashboardWidgetConfigs()

        widgets.add_widget(WidgetConfig({
            'width': 3,
            'name': 'widget1',
            'type': 'diamondash.widgets.widget.Widget',
        }))

        widgets.add_widget(WidgetConfig({
            'width': 8,
            'name': 'widget2',
            'type': 'diamondash.widgets.widget.Widget',
        }))

        widgets.add_widget(WidgetConfig({
            'width': 3,
            'name': 'widget3',
            'type': 'diamondash.widgets.widget.Widget',
        }))

        widgets.add_widget(WidgetConfig({
            'width': 4,
            'name': 'widget4',
            'type': 'diamondash.widgets.widget.Widget',
        }))
Beispiel #2
0
    def test_widget_parsing_for_static_widgets(self):
        widgets = DashboardWidgetConfigs({
            'type': 'diamondash.tests.utils.ToyBackend',
            'url': 'http://127.0.0.1:3000',
        })

        config = widgets.parse_widget({
            'name': 'widget1',
            'type': 'diamondash.widgets.widget.Widget',
        })

        self.assertTrue(isinstance(config, WidgetConfig))
        self.assertTrue(config['name'], 'widget1')
        self.assertTrue('backend' not in config)
Beispiel #3
0
    def test_widget_parsing_for_dynamic_widgets(self):
        widgets = DashboardWidgetConfigs({
            'type': 'diamondash.tests.utils.ToyBackend',
            'url': 'http://127.0.0.1:3000',
        })

        config = widgets.parse_widget({
            'name': 'widget2',
            'type': 'diamondash.tests.utils.ToyDynamicWidget',
        })

        self.assertTrue(isinstance(config, DynamicWidgetConfig))
        self.assertTrue(config['name'], 'widget2')
        self.assertEqual(config['backend'], {
            'type': 'diamondash.tests.utils.ToyBackend',
            'url': 'http://127.0.0.1:3000',
            'metrics': [],
        })