Exemplo n.º 1
0
def test_widget_basic():
    """Basic widget usage"""
    widget = CodeMirrorWidget(config_name="basic")

    rendered = widget.render("sample", "Hello World!")

    assert rendered == ("""<textarea cols="40" name="sample" rows="10">\r\n""" """Hello World!</textarea>""")
Exemplo n.º 2
0
 class Meta:
     model = Datacheck
     fields = ['code', 'description', 'weight', 'left_system', 'left_type', 'left_logic', 'relation', 'right_system',
               'right_type', 'right_logic',
               'supports_warning', 'warning_relation', 'warning_type', 'warning_logic', 'group']
     widgets = {
         'description': forms.Textarea({'cols': 40, 'rows': 3}),
         'left_logic': CodeMirrorWidget(config_name='inspector'),
         'right_logic': CodeMirrorWidget(config_name='inspector'),
         'warning_logic': CodeMirrorWidget(config_name='inspector')
     }
     system_icon = '<i class="fas fa-desktop" title="System"></i>'
     logic_icon = '<i class="fas fa-code" title="Logic"></i>'
     group_icon = '<i class="far fa-object-ungroup" title="Group"></i>'
     labels = {
         'left_system': system_icon,
         'left_type': 'Type',
         'left_logic': logic_icon,
         'right_system': system_icon,
         'right_type': 'Type',
         'right_logic': logic_icon,
         'warning_type': 'Type',
         'warning_relation': 'Relation',
         'warning_logic': logic_icon,
         'supports_warning': 'Enabled',
         'code': False,
         'weight': False,
         'group': group_icon
     }
def test_widget_basic():
    """Basic widget usage"""
    widget = CodeMirrorWidget(config_name="basic")

    rendered = widget.render("sample", "Hello World!")

    assert rendered == ("""<textarea cols="40" name="sample" rows="10">\r\n"""
                        """Hello World!</textarea>""")
Exemplo n.º 4
0
def test_widget_basic():
    """Basic widget usage"""
    widget = CodeMirrorWidget(config_name="basic")

    rendered = widget.render("sample", "Hello World!")

    expected = ("""<textarea id="id_sample" name="sample" rows="10" cols="40">"""
                """Hello World!</textarea>""")

    assert assert_and_parse_html(rendered) == assert_and_parse_html(expected)
Exemplo n.º 5
0
def test_widget_init_manifest():
    """Check registered config"""
    widget = CodeMirrorWidget(config_name="empty")

    config = widget.init_manifest("empty")

    assert config.get_configs() == {
        "empty": {
            "modes": [],
            "addons": [],
            "themes": [],
            "css_bundle_name": "dcm-empty_css",
            "js_bundle_name": "dcm-empty_js",
        }
    }
def test_widget_init_manifest():
    """Check registered config"""
    widget = CodeMirrorWidget(config_name="empty")

    config = widget.init_manifest("empty")

    assert config.get_configs() == {
        'empty': {
            'modes': [],
            'addons': [],
            'themes': [],
            'css_bundle_name': 'dcm-empty_css',
            'js_bundle_name': 'dcm-empty_js',
        }
    }
Exemplo n.º 7
0
def test_widget_init_manifest():
    """Check registered config"""
    widget = CodeMirrorWidget(config_name="empty")

    config = widget.init_manifest("empty")

    assert config.get_configs() == {
        'empty': {
            'modes': [],
            'addons': [],
            'themes': [],
            'css_bundle_name': 'dcm-empty_css',
            'js_bundle_name': 'dcm-empty_js',
        }
    }
Exemplo n.º 8
0
 class Meta:
     model = Datacheck
     fields = [
         "code",
         "description",
         "weight",
         "left_system",
         "left_type",
         "left_logic",
         "relation",
         "right_system",
         "right_type",
         "right_logic",
         "supports_warning",
         "warning_relation",
         "warning_type",
         "warning_logic",
         "tags",
     ]
     widgets = {
         "description": forms.Textarea({
             "cols": 40,
             "rows": 3
         }),
         "left_logic": CodeMirrorWidget(config_name="inspector"),
         "right_logic": CodeMirrorWidget(config_name="inspector"),
         "warning_logic": CodeMirrorWidget(config_name="inspector"),
     }
     system_icon = fa_icon("desktop", "System")
     labels = {
         "left_system": system_icon,
         "left_type": "Type",
         "left_logic": fa_icon("code", "Logic"),
         "right_system": system_icon,
         "right_type": "Type",
         "right_logic": fa_icon("code", "Logic"),
         "warning_type": "Type",
         "warning_relation": "Relation",
         "warning_logic": fa_icon("code", "Logic"),
         "supports_warning": "Enabled",
         "code": False,
         "weight": False,
         "tags": False,
     }
def test_widget_medias(name, attempted):
    """Get widget medias"""
    widget = CodeMirrorWidget(config_name=name)
    medias = str(widget.media)

    assert medias == attempted