Ejemplo n.º 1
0
def test_form_basic():
    """Basic field usage"""
    f = SampleForm({'foo': 'bar'})

    assert f.as_p() == ("""<p><label for="id_foo">Foo:</label> """
                        """<textarea cols="40" id="id_foo" name="foo" """
                        """rows="10">\r\nbar</textarea></p>""")
Ejemplo n.º 2
0
def test_codemirror_single_field_js_assets():
    """Test codemirror_field_js_assets tag for a single field"""
    f = SampleForm()

    f.as_p()

    assets = codemirror_field_js_assets(f.fields['foo'])

    assert assets == """<script type="text/javascript" src="/static/CodeMirror/lib/codemirror.js"></script>"""
Ejemplo n.º 3
0
def test_codemirror_single_field_js_assets():
    """Test codemirror_field_js_assets tag for a single field"""
    f = SampleForm()

    f.as_p()

    assets = codemirror_field_js_assets(f.fields['foo'])

    assert assets == """<script type="text/javascript" src="/static/CodeMirror/lib/codemirror.js"></script>"""
Ejemplo n.º 4
0
def test_codemirror_single_field_js_assets():
    """Test codemirror_field_js_assets tag for a single field"""
    f = SampleForm()

    f.as_p()

    assets = codemirror_field_css_assets(f.fields['foo'])

    assert assets == '<link rel="stylesheet" href="/static/CodeMirror/lib/codemirror.css">'
Ejemplo n.º 5
0
def test_codemirror_single_field_js_assets():
    """Test codemirror_field_js_assets tag for a single field"""
    f = SampleForm()

    f.as_p()

    assets = codemirror_field_css_assets(f.fields['foo'])

    assert assets == '<link rel="stylesheet" href="/static/CodeMirror/lib/codemirror.css">'
Ejemplo n.º 6
0
def test_css_html(settings):
    manifesto = CodemirrorAssetTagRender()

    f = SampleForm()
    f.as_p()

    manifesto.register_from_fields(f.fields['foo'], )

    assets = manifesto.css_html()

    assert assets == '<link rel="stylesheet" href="/static/CodeMirror/lib/codemirror.css">'
Ejemplo n.º 7
0
def test_css_html(settings):
    manifesto = CodemirrorAssetTagRender()

    f = SampleForm()
    f.as_p()

    manifesto.register_from_fields(
        f.fields['foo'],
    )

    assets = manifesto.css_html()

    assert assets == '<link rel="stylesheet" href="/static/CodeMirror/lib/codemirror.css">'
Ejemplo n.º 8
0
def test_form_basic():
    """Basic field usage"""
    f = SampleForm({'foo': 'bar'})

    if django_versioning[1] < 10:
        assert f.as_p() == ("""<p><label for="id_foo">Foo:</label> """
                            """<textarea cols="40" id="id_foo" name="foo" """
                            """rows="10">\r\nbar</textarea></p>""")
    else:
        # Since Django 1.10, required form fields set the required HTML
        assert f.as_p() == ("""<p><label for="id_foo">Foo:</label> """
                            """<textarea cols="40" id="id_foo" name="foo" """
                            """rows="10" required>\r\nbar</textarea></p>""")
Ejemplo n.º 9
0
def test_resolve_widget():
    """
    Check widget resolving from a field

    Note:
        We should test also against BoundField but it seems to involve template
        resolving and i'm too lazy for that now.
    """
    f = SampleForm()

    w = CodemirrorAssetTagRender().resolve_widget(f.fields['foo'])

    assert isinstance(w, CodeMirrorWidget) == True