示例#1
0
def test_crispy_addon(settings):
    test_form = SampleForm()
    field_instance = test_form.fields["email"]
    bound_field = BoundField(test_form, field_instance, "email")

    assert "input-group-text" in crispy_addon(bound_field,
                                              prepend="Work",
                                              append="Primary")
    assert "input-group-text" in crispy_addon(bound_field,
                                              prepend="Work",
                                              append="Secondary")

    # errors
    with pytest.raises(TypeError):
        crispy_addon()
    with pytest.raises(TypeError):
        crispy_addon(bound_field)
def test_crispy_addon(settings):
    test_form = TestForm()
    field_instance = test_form.fields['email']
    bound_field = BoundField(test_form, field_instance, 'email')

    if settings.CRISPY_TEMPLATE_PACK == 'bootstrap':
        # prepend tests
        assert "input-prepend" in crispy_addon(bound_field, prepend="Work")
        assert "input-append" not in crispy_addon(bound_field, prepend="Work")
        # append tests
        assert "input-prepend" not in crispy_addon(bound_field, append="Primary")
        assert "input-append" in crispy_addon(bound_field, append="Secondary")
        # prepend and append tests
        assert "input-append" in crispy_addon(bound_field, prepend="Work", append="Primary")
        assert "input-prepend" in crispy_addon(bound_field, prepend="Work", append="Secondary")
    elif settings.CRISPY_TEMPLATE_PACK in ['bootstrap3', 'bootstrap4']:
        assert "input-group-addon" in crispy_addon(bound_field, prepend="Work", append="Primary")
        assert "input-group-addon" in crispy_addon(bound_field, prepend="Work", append="Secondary")

    # errors
    with pytest.raises(TypeError):
        crispy_addon()
    with pytest.raises(TypeError):
        crispy_addon(bound_field)
示例#3
0
def test_crispy_addon(settings):
    test_form = SampleForm()
    field_instance = test_form.fields['email']
    bound_field = BoundField(test_form, field_instance, 'email')

    if settings.CRISPY_TEMPLATE_PACK == 'bootstrap':
        # prepend tests
        assert "input-prepend" in crispy_addon(bound_field, prepend="Work")
        assert "input-append" not in crispy_addon(bound_field, prepend="Work")
        # append tests
        assert "input-prepend" not in crispy_addon(bound_field, append="Primary")
        assert "input-append" in crispy_addon(bound_field, append="Secondary")
        # prepend and append tests
        assert "input-append" in crispy_addon(bound_field, prepend="Work", append="Primary")
        assert "input-prepend" in crispy_addon(bound_field, prepend="Work", append="Secondary")
    elif settings.CRISPY_TEMPLATE_PACK == 'bootstrap3':
        assert "input-group-addon" in crispy_addon(bound_field, prepend="Work", append="Primary")
        assert "input-group-addon" in crispy_addon(bound_field, prepend="Work", append="Secondary")
    elif settings.CRISPY_TEMPLATE_PACK == 'bootstrap4':
        assert "input-group-text" in crispy_addon(bound_field, prepend="Work", append="Primary")
        assert "input-group-text" in crispy_addon(bound_field, prepend="Work", append="Secondary")

    # errors
    with pytest.raises(TypeError):
        crispy_addon()
    with pytest.raises(TypeError):
        crispy_addon(bound_field)
    def test_crispy_addon(self):
        test_form = TestForm()
        field_instance = test_form.fields['email']
        bound_field = BoundField(test_form, field_instance, 'email')

        if self.current_template_pack == 'bootstrap':
            # prepend tests
            self.assertIn("input-prepend", crispy_addon(bound_field, prepend="Work"))
            self.assertNotIn("input-append", crispy_addon(bound_field, prepend="Work"))
            # append tests
            self.assertNotIn("input-prepend", crispy_addon(bound_field, append="Primary"))
            self.assertIn("input-append", crispy_addon(bound_field, append="Secondary"))
            # prepend and append tests
            self.assertIn("input-append", crispy_addon(bound_field, prepend="Work", append="Primary"))
            self.assertIn("input-prepend", crispy_addon(bound_field, prepend="Work", append="Secondary"))
        elif self.current_template_pack == 'bootsrap3':
            self.assertIn("input-group-addon", crispy_addon(bound_field, prepend="Work", append="Primary"))
            self.assertIn("input-group-addon", crispy_addon(bound_field, prepend="Work", append="Secondary"))

        # errors
        with self.assertRaises(TypeError):
            crispy_addon()
            crispy_addon(bound_field)
示例#5
0
文件: test_tags.py 项目: qaz3320/Jeap
    def test_crispy_addon(self):
        test_form = TestForm()
        field_instance = test_form.fields['email']
        bound_field = BoundField(test_form, field_instance, 'email')

        if self.current_template_pack == 'bootstrap':
            # prepend tests
            self.assertIn("input-prepend",
                          crispy_addon(bound_field, prepend="Work"))
            self.assertNotIn("input-append",
                             crispy_addon(bound_field, prepend="Work"))
            # append tests
            self.assertNotIn("input-prepend",
                             crispy_addon(bound_field, append="Primary"))
            self.assertIn("input-append",
                          crispy_addon(bound_field, append="Secondary"))
            # prepend and append tests
            self.assertIn(
                "input-append",
                crispy_addon(bound_field, prepend="Work", append="Primary"))
            self.assertIn(
                "input-prepend",
                crispy_addon(bound_field, prepend="Work", append="Secondary"))
        elif self.current_template_pack == 'bootsrap3':
            self.assertIn(
                "input-group-addon",
                crispy_addon(bound_field, prepend="Work", append="Primary"))
            self.assertIn(
                "input-group-addon",
                crispy_addon(bound_field, prepend="Work", append="Secondary"))

        # errors
        with self.assertRaises(TypeError):
            crispy_addon()
            crispy_addon(bound_field)