How to use the cartoframes.viz.Widget function in cartoframes

To help you get started, we’ve selected a few cartoframes examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github CartoDB / cartoframes / test / viz / test_widget_list.py View on Github external
def test_widget_list_init_with_a_list_of_widgets(self):
        """WidgetList should be properly initialized"""

        widget_list = WidgetList([
            Widget(widget_a),
            Widget(widget_b)
        ])

        self.assertTrue(isinstance(widget_list._widgets[0], Widget))
        self.assertTrue(isinstance(widget_list._widgets[1], Widget))
github CartoDB / cartoframes / tests / unit / viz / test_widget_list.py View on Github external
def test_widget_list_get_widgets_info(self):
        """Widget List should return a proper widgets info object"""

        widget_list = WidgetList([
            Widget(WIDGET_A),
            Widget(WIDGET_B)
        ])

        widgets_info = widget_list.get_widgets_info()
        assert widgets_info == [
            {
                'type': 'formula',
                'value': 'viewportSum($amount)',
                'title': '[TITLE]',
                'prop': '',
                'description': '[description]',
                'footer': '[footer]',
                'has_bridge': False,
                'variable_name': 'vb6dbcf',
                'options': {
                    'readOnly': False,
                    'buckets': 20
github CartoDB / cartoframes / tests / unit / viz / test_widget.py View on Github external
def test_animation_widget(self):
        """An Animation widget should be created successfully with the default property"""
        widget = Widget({
            'type': 'animation',
        })

        assert widget.get_info() == {
            'type': 'animation',
            'title': '',
            'value': '',
            'description': '',
            'footer': '',
            'has_bridge': True,
            'prop': 'filter',
            'variable_name': '',
            'options': {
                'readOnly': False,
                'buckets': 20
            }
github CartoDB / cartoframes / tests / unit / viz / test_widget.py View on Github external
def test_widget_info(self):
        """Widget should return a proper information object"""
        widget = Widget({
            'type': 'formula',
            'value': 'viewportSum($amount)',
            'title': '[TITLE]',
            'description': '[description]',
            'footer': '[footer]'
        })

        assert widget.get_info() == {
            'type': 'formula',
            'value': 'viewportSum($amount)',
            'title': '[TITLE]',
            'description': '[description]',
            'footer': '[footer]',
            'has_bridge': False,
            'prop': '',
            'variable_name': 'vb6dbcf',
github CartoDB / cartoframes / tests / unit / viz / test_widget.py View on Github external
def test_wrong_type(self):
        """Widget should raise an error if widget type is not valid"""
        msg = 'Widget type is not valid. Valid widget types are: ' + \
            'default, formula, histogram, category, animation, time-series.'

        with pytest.raises(ValueError) as e:
            Widget({'type': 'xxx'}).get_info()
        assert str(e.value) == msg
github CartoDB / cartoframes / test / viz / test_widget_list.py View on Github external
def test_widget_list_get_widgets_info(self):
        """Widget List should return a proper widgets info object"""

        widget_list = WidgetList([
            Widget(widget_a),
            Widget(widget_b)
        ])

        widgets_info = widget_list.get_widgets_info()
        self.assertEqual(widgets_info, [
            {
                'type': 'formula',
                'value': 'viewportSum($amount)',
                'title': '[TITLE]',
                'prop': '',
                'description': '[description]',
                'footer': '[footer]',
                'has_bridge': False,
                'variable_name': 'vb6dbcf',
                'options': {
                    'readOnly': False,
                    'buckets': 20
github CartoDB / cartoframes / test / viz / test_widget_list.py View on Github external
def test_widget_list_init_with_a_list_of_widgets(self):
        """WidgetList should be properly initialized"""

        widget_list = WidgetList([
            Widget(widget_a),
            Widget(widget_b)
        ])

        self.assertTrue(isinstance(widget_list._widgets[0], Widget))
        self.assertTrue(isinstance(widget_list._widgets[1], Widget))
github CartoDB / cartoframes / tests / unit / viz / test_widget_list.py View on Github external
def test_widget_list_init_with_a_list_of_widgets(self):
        """WidgetList should be properly initialized"""

        widget_list = WidgetList([
            Widget(WIDGET_A),
            Widget(WIDGET_B)
        ])

        assert isinstance(widget_list._widgets[0], Widget)
        assert isinstance(widget_list._widgets[1], Widget)
github CartoDB / cartoframes / tests / unit / viz / test_widget_list.py View on Github external
def test_widget_list_init_with_a_list_of_dict(self):
        """WidgetList should be properly initialized"""

        widget_list = WidgetList([WIDGET_A, WIDGET_B])

        assert widget_list._widgets[0]._type == 'formula'
        assert widget_list._widgets[0]._value == 'viewportSum($amount)'
        assert widget_list._widgets[0]._title == '[TITLE]'
        assert widget_list._widgets[0]._description == '[description]'
        assert widget_list._widgets[0]._footer == '[footer]'
        assert isinstance(widget_list._widgets[0], Widget)

        assert widget_list._widgets[1]._type == 'default'
        assert widget_list._widgets[1]._title == '"Custom Info"'
        assert widget_list._widgets[1]._description == ''
        assert widget_list._widgets[1]._footer == ''
        assert isinstance(widget_list._widgets[1], Widget)
github CartoDB / cartoframes / test / viz / test_widget.py View on Github external
def test_animation_widget_prop(self):
        """An Animation widget should be created successfully with a custom property"""
        widget = Widget({
            'type': 'animation',
            'prop': 'width'
        })

        self.assertEqual(widget.get_info(), {
            'type': 'animation',
            'title': '',
            'value': '',
            'description': '',
            'footer': '',
            'has_bridge': True,
            'prop': 'width',
            'variable_name': '',
            'options': {
                'readOnly': False,
                'buckets': 20