Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main'
Browse files Browse the repository at this point in the history
  • Loading branch information
michael-yin committed Sep 11, 2024
2 parents 9e460e9 + 56870f5 commit 89c11b0
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 24 deletions.
2 changes: 1 addition & 1 deletion src/django_formify/tailwind/formify_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class FormifyHelper:
# and access them in template via formify_helper.xxx
form_show_errors = True
form_show_labels = True
field_wrapper_class = "mb-3"
field_wrapper_class = "field-wrapper mb-3"
# this is the component used to render the label, field input and error messages
field_wrapper_component = "formify.tw.field_wrapper"
field_class = "form-control"
Expand Down
2 changes: 1 addition & 1 deletion src/django_formify/templates/formify/tailwind/select.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{% load l10n formify %}
{% load l10n formify viewcomponent_tags %}

{% component formify_helper.field_wrapper_component as field_component %}
{% call field_component.label %}
Expand Down
44 changes: 22 additions & 22 deletions tests/test_form_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def test_render_all_supported_fields(self, mocker):
html = template.render(Context({"form": AllFieldsForm()}))

mock_text_input.assert_called_once()
assert_select(html, ".form-group", 1)
assert_select(html, ".field-wrapper", 1)

def test_render_email_field(self, mocker):
mock_email_input = mocker.spy(FormifyHelper, "email_input")
Expand All @@ -40,7 +40,7 @@ def test_render_email_field(self, mocker):
html = template.render(Context({"form": AllFieldsForm()}))

mock_email_input.assert_called_once()
assert_select(html, ".form-group", 1)
assert_select(html, ".field-wrapper", 1)

def test_render_integer_field(self, mocker):
mock_number_input = mocker.spy(FormifyHelper, "number_input")
Expand All @@ -54,7 +54,7 @@ def test_render_integer_field(self, mocker):
html = template.render(Context({"form": AllFieldsForm()}))

mock_number_input.assert_called_once()
assert_select(html, ".form-group", 1)
assert_select(html, ".field-wrapper", 1)

def test_render_float_field(self, mocker):
mock_number_input = mocker.spy(FormifyHelper, "number_input")
Expand All @@ -68,7 +68,7 @@ def test_render_float_field(self, mocker):
html = template.render(Context({"form": AllFieldsForm()}))

mock_number_input.assert_called_once()
assert_select(html, ".form-group", 1)
assert_select(html, ".field-wrapper", 1)

def test_render_boolean_field(self, mocker):
mock_checkbox_input = mocker.spy(FormifyHelper, "checkbox_input")
Expand All @@ -82,7 +82,7 @@ def test_render_boolean_field(self, mocker):
html = template.render(Context({"form": AllFieldsForm()}))

mock_checkbox_input.assert_called_once()
assert_select(html, ".form-group", 1)
assert_select(html, ".field-wrapper", 1)

def test_render_date_field(self, mocker):
mock_date_input = mocker.spy(FormifyHelper, "date_input")
Expand All @@ -96,7 +96,7 @@ def test_render_date_field(self, mocker):
html = template.render(Context({"form": AllFieldsForm()}))

mock_date_input.assert_called_once()
assert_select(html, ".form-group", 1)
assert_select(html, ".field-wrapper", 1)

def test_render_time_field(self, mocker):
mock_time_input = mocker.spy(FormifyHelper, "time_input")
Expand All @@ -110,7 +110,7 @@ def test_render_time_field(self, mocker):
html = template.render(Context({"form": AllFieldsForm()}))

mock_time_input.assert_called_once()
assert_select(html, ".form-group", 1)
assert_select(html, ".field-wrapper", 1)

def test_render_datetime_field(self, mocker):
mock_date_time_input = mocker.spy(FormifyHelper, "date_time_input")
Expand All @@ -124,7 +124,7 @@ def test_render_datetime_field(self, mocker):
html = template.render(Context({"form": AllFieldsForm()}))

mock_date_time_input.assert_called_once()
assert_select(html, ".form-group", 1)
assert_select(html, ".field-wrapper", 1)

def test_render_choice_field(self, mocker):
mock_select = mocker.spy(FormifyHelper, "select")
Expand All @@ -138,7 +138,7 @@ def test_render_choice_field(self, mocker):
html = template.render(Context({"form": AllFieldsForm()}))

mock_select.assert_called_once()
assert_select(html, ".form-group", 1)
assert_select(html, ".field-wrapper", 1)

def test_render_choice_radio_field(self, mocker):
mock_radio_select = mocker.spy(FormifyHelper, "radio_select")
Expand All @@ -152,7 +152,7 @@ def test_render_choice_radio_field(self, mocker):
html = template.render(Context({"form": AllFieldsForm()}))

mock_radio_select.assert_called_once()
assert_select(html, ".form-group", 1)
assert_select(html, ".field-wrapper", 1)

def test_render_select_multiple(self, mocker):
mock_select_multiple = mocker.spy(FormifyHelper, "select_multiple")
Expand All @@ -166,7 +166,7 @@ def test_render_select_multiple(self, mocker):
html = template.render(Context({"form": AllFieldsForm()}))

mock_select_multiple.assert_called_once()
assert_select(html, ".form-group", 1)
assert_select(html, ".field-wrapper", 1)

def test_render_checkbox_select_multiple(self, mocker):
mock_checkbox_select_multiple = mocker.spy(
Expand All @@ -182,7 +182,7 @@ def test_render_checkbox_select_multiple(self, mocker):
html = template.render(Context({"form": AllFieldsForm()}))

mock_checkbox_select_multiple.assert_called_once()
assert_select(html, ".form-group", 1)
assert_select(html, ".field-wrapper", 1)

def test_render_file_field(self, mocker):
mock_clearable_file_input = mocker.spy(FormifyHelper, "clearable_file_input")
Expand All @@ -196,7 +196,7 @@ def test_render_file_field(self, mocker):
html = template.render(Context({"form": AllFieldsForm()}))

mock_clearable_file_input.assert_called_once()
assert_select(html, ".form-group", 1)
assert_select(html, ".field-wrapper", 1)

def test_render_image_field(self, mocker):
mock_clearable_file_input = mocker.spy(FormifyHelper, "clearable_file_input")
Expand All @@ -210,7 +210,7 @@ def test_render_image_field(self, mocker):
html = template.render(Context({"form": AllFieldsForm()}))

mock_clearable_file_input.assert_called_once()
assert_select(html, ".form-group", 1)
assert_select(html, ".field-wrapper", 1)

def test_render_url_field(self, mocker):
mock_url_input = mocker.spy(FormifyHelper, "url_input")
Expand All @@ -224,7 +224,7 @@ def test_render_url_field(self, mocker):
html = template.render(Context({"form": AllFieldsForm()}))

mock_url_input.assert_called_once()
assert_select(html, ".form-group", 1)
assert_select(html, ".field-wrapper", 1)

def test_render_regex_field(self, mocker):
mock_text_input = mocker.spy(FormifyHelper, "text_input")
Expand All @@ -238,7 +238,7 @@ def test_render_regex_field(self, mocker):
html = template.render(Context({"form": AllFieldsForm()}))

mock_text_input.assert_called_once()
assert_select(html, ".form-group", 1)
assert_select(html, ".field-wrapper", 1)

def test_render_hidden_field(self):
template = Template(
Expand All @@ -262,7 +262,7 @@ def test_render_textarea_field(self, mocker):
html = template.render(Context({"form": AllFieldsForm()}))

mock_text_input.assert_called_once()
assert_select(html, ".form-group", 1)
assert_select(html, ".field-wrapper", 1)

def test_render_password_input_field(self, mocker):
mock_text_input = mocker.spy(FormifyHelper, "password_input")
Expand All @@ -276,14 +276,14 @@ def test_render_password_input_field(self, mocker):
html = template.render(Context({"form": AllFieldsForm()}))

mock_text_input.assert_called_once()
assert_select(html, ".form-group", 1)
assert_select(html, ".field-wrapper", 1)


class TestFormFormifyHelper:
def test_custom_formify_helper(self):
helper = FormifyHelper()
helper.form_show_errors = False
helper.field_wrapper_class = "another-form-group"
helper.field_wrapper_class = "another-field-wrapper"

template = Template(
"""
Expand All @@ -299,8 +299,8 @@ def test_custom_formify_helper(self):
c = Context({"testForm": form})
html = template.render(c)

assert_select(html, ".form-group", 0)
assert_select(html, ".another-form-group")
assert_select(html, ".field-wrapper", 0)
assert_select(html, ".another-field-wrapper")
assert_select(html, ".form-non-field-errors", 0)

def test_override_in_field(self):
Expand All @@ -325,5 +325,5 @@ def test_override_in_field(self):
c = Context({"testForm": form})
html = template.render(c)

assert_select(html, ".form-group")
assert_select(html, ".field-wrapper")
assert_select(html, "label", 1)

0 comments on commit 89c11b0

Please sign in to comment.