# Path: crispy_forms_foundation/layout/base.py
# class Layout(crispy_forms_layout.Layout):
#     pass
# 
# Path: crispy_forms_foundation/layout/fields.py
# class InlineField(Field):
#     """
#     Layout object for rendering an inline field with Foundation
# 
#     Example:
# 
#     .. sourcecode:: python
# 
#         InlineField('field_name')
# 
#     Or:
# 
#     .. sourcecode:: python
# 
#         InlineField('field_name', label_column='large-8',
#                     input_column='large-4', label_class='')
# 
#     ``label_column``, ``input_column``, ``label_class``, are optional argument.
#     """
#     template = "%s/layout/inline_field.html"
# 
#     def __init__(self, field, label_column='large-3', input_column='large-9',
#                  label_class='', *args, **kwargs):
#         self.field = field
#         self.label_column = label_column+' columns'
#         self.input_column = input_column+' columns'
#         self.label_class = label_class
# 
#         super(InlineField, self).__init__(field, *args, **kwargs)
# 
#     def render(self, form, form_style, context, template_pack=TEMPLATE_PACK):
#         context['label_column'] = self.label_column
#         context['input_column'] = self.input_column
#         context['label_class'] = self.label_class
# 
#         html = ''
#         template = self.get_template_name(template_pack)
#         for field in self.fields:
#             html += render_field(field, form, form_style, context,
#                                  template=template, attrs=self.attrs,
#                                  template_pack=template_pack)
#         return html
# 
# class InlineSwitchField(InlineField):
#     """
#     Like ``SwitchField`` it use Foundation form switches with checkbox field
#     but within an ``InlineField``
# 
#     Contrary to ``SwitchField`` this play nice with the label to be able to
#     display it (as Foundation form switches default behavior is to hide the
#     label text)
# 
#     Example:
# 
#     .. sourcecode:: python
# 
#         InlineSwitchField('field_name')
# 
#     Or:
# 
#     .. sourcecode:: python
# 
#         InlineSwitchField('field_name', label_column='large-8',
#                           input_column='large-4', label_class='',
#                           switch_class="inline")
# 
#     ``label_column``, ``input_column``, ``label_class``, ``switch_class`` are
#     optional argument.
#     """
#     template = "%s/inline_switch.html"
# 
#     def __init__(self, field, *args, **kwargs):
#         self.switch_class = ['switch']+kwargs.pop('switch_class', '').split()
#         kwargs['label_column'] = kwargs.pop('label_column', 'large-8')
#         kwargs['input_column'] = kwargs.pop('input_column', 'large-4')
#         kwargs['class'] = (kwargs.pop('class', '') + ' switch-input').strip()
# 
#         super(InlineSwitchField, self).__init__(field, *args, **kwargs)
# 
#     def render(self, form, form_style, context, template_pack=TEMPLATE_PACK):
#         context['switch_class'] = " ".join(self.switch_class)
#         return super(InlineSwitchField, self).render(form, form_style, context,
#                                                      template_pack)
# 
# class FakeField(Field):
#     """
#     Fake field is intended to be used with some app that does not honor field
#     ID on the input element alike ``django-recaptcha`` that build a textarea
#     with a dummy ID attribute. This leads to HTML validation error.
# 
#     Fake field works as basic Field object except a ``fake_field`` variable is
#     passed to the template context.
# 
#     Actually the only difference with a ``Field`` is label element drops
#     ``for`` attribute.
# 
#     You should use this field in last resort.
#     """
#     def render(self, form, form_style, context, template_pack=TEMPLATE_PACK):
#         context['fake_field'] = True
#         return super(FakeField, self).render(form, form_style, context,
#                                              template_pack)
# 
# Path: tests/forms.py
# class BasicInputForm(forms.Form):
#     """
#     Basic form with a single CharField field
#     """
#     simple = forms.CharField(label='Simple text',
#                              widget=forms.TextInput(attrs={'required':''}),
#                              required=True)
# 
#     def save(self, commit=True):
#         return
# 
# class BoolInputForm(forms.Form):
#     """
#     Basic form with a single BooleanField field
#     """
#     opt_in = forms.BooleanField(
#             label="Opt in",
#             widget=forms.CheckboxInput(attrs={'required': ''}),
#             required=True)
# 
#     def save(self, commit=True):
#         return


import os
import pytest
from django.test.html import parse_html
from crispy_forms_foundation.layout import (Layout, InlineField,
                                            InlineSwitchField, FakeField)
from tests.forms import BasicInputForm, BoolInputForm


#from tests.utils import write_output


def test_fakefield(output_test_path, render_output, rendered_template,
                     helper, client):
    form = BasicInputForm()
    pack = helper.template_pack

    helper.layout = Layout(
        FakeField('simple')
    )

    rendered = rendered_template(form, helper=helper)

    attempted = render_output(os.path.join(output_test_path, pack,
                                           "test_fakefield.html"))
    #write_output(output_test_path, pack, "test_fakefield.html", rendered)

    assert parse_html(attempted) == parse_html(rendered)


def test_inlinefield(output_test_path, render_output, rendered_template,
                     helper, client):

# Path: crispy_forms_foundation/layout/base.py
# class Layout(crispy_forms_layout.Layout):
#     pass
# 
# Path: crispy_forms_foundation/layout/fields.py
# class InlineField(Field):
#     """
#     Layout object for rendering an inline field with Foundation
# 
#     Example:
# 
#     .. sourcecode:: python
# 
#         InlineField('field_name')
# 
#     Or:
# 
#     .. sourcecode:: python
# 
#         InlineField('field_name', label_column='large-8',
#                     input_column='large-4', label_class='')
# 
#     ``label_column``, ``input_column``, ``label_class``, are optional argument.
#     """
#     template = "%s/layout/inline_field.html"
# 
#     def __init__(self, field, label_column='large-3', input_column='large-9',
#                  label_class='', *args, **kwargs):
#         self.field = field
#         self.label_column = label_column+' columns'
#         self.input_column = input_column+' columns'
#         self.label_class = label_class
# 
#         super(InlineField, self).__init__(field, *args, **kwargs)
# 
#     def render(self, form, form_style, context, template_pack=TEMPLATE_PACK):
#         context['label_column'] = self.label_column
#         context['input_column'] = self.input_column
#         context['label_class'] = self.label_class
# 
#         html = ''
#         template = self.get_template_name(template_pack)
#         for field in self.fields:
#             html += render_field(field, form, form_style, context,
#                                  template=template, attrs=self.attrs,
#                                  template_pack=template_pack)
#         return html
# 
# class InlineSwitchField(InlineField):
#     """
#     Like ``SwitchField`` it use Foundation form switches with checkbox field
#     but within an ``InlineField``
# 
#     Contrary to ``SwitchField`` this play nice with the label to be able to
#     display it (as Foundation form switches default behavior is to hide the
#     label text)
# 
#     Example:
# 
#     .. sourcecode:: python
# 
#         InlineSwitchField('field_name')
# 
#     Or:
# 
#     .. sourcecode:: python
# 
#         InlineSwitchField('field_name', label_column='large-8',
#                           input_column='large-4', label_class='',
#                           switch_class="inline")
# 
#     ``label_column``, ``input_column``, ``label_class``, ``switch_class`` are
#     optional argument.
#     """
#     template = "%s/inline_switch.html"
# 
#     def __init__(self, field, *args, **kwargs):
#         self.switch_class = ['switch']+kwargs.pop('switch_class', '').split()
#         kwargs['label_column'] = kwargs.pop('label_column', 'large-8')
#         kwargs['input_column'] = kwargs.pop('input_column', 'large-4')
#         kwargs['class'] = (kwargs.pop('class', '') + ' switch-input').strip()
# 
#         super(InlineSwitchField, self).__init__(field, *args, **kwargs)
# 
#     def render(self, form, form_style, context, template_pack=TEMPLATE_PACK):
#         context['switch_class'] = " ".join(self.switch_class)
#         return super(InlineSwitchField, self).render(form, form_style, context,
#                                                      template_pack)
# 
# class FakeField(Field):
#     """
#     Fake field is intended to be used with some app that does not honor field
#     ID on the input element alike ``django-recaptcha`` that build a textarea
#     with a dummy ID attribute. This leads to HTML validation error.
# 
#     Fake field works as basic Field object except a ``fake_field`` variable is
#     passed to the template context.
# 
#     Actually the only difference with a ``Field`` is label element drops
#     ``for`` attribute.
# 
#     You should use this field in last resort.
#     """
#     def render(self, form, form_style, context, template_pack=TEMPLATE_PACK):
#         context['fake_field'] = True
#         return super(FakeField, self).render(form, form_style, context,
#                                              template_pack)
# 
# Path: tests/forms.py
# class BasicInputForm(forms.Form):
#     """
#     Basic form with a single CharField field
#     """
#     simple = forms.CharField(label='Simple text',
#                              widget=forms.TextInput(attrs={'required':''}),
#                              required=True)
# 
#     def save(self, commit=True):
#         return
# 
# class BoolInputForm(forms.Form):
#     """
#     Basic form with a single BooleanField field
#     """
#     opt_in = forms.BooleanField(
#             label="Opt in",
#             widget=forms.CheckboxInput(attrs={'required': ''}),
#             required=True)
# 
#     def save(self, commit=True):
#         return


# Path: tests/003_fields.py
import os
import pytest
from django.test.html import parse_html
from crispy_forms_foundation.layout import (Layout, InlineField,
                                            InlineSwitchField, FakeField)
from tests.forms import BasicInputForm, BoolInputForm



#from tests.utils import write_output


def test_fakefield(output_test_path, render_output, rendered_template,
                     helper, client):
    form = BasicInputForm()
    pack = helper.template_pack

    helper.layout = Layout(
        FakeField('simple')
    )

    rendered = rendered_template(form, helper=helper)

    attempted = render_output(os.path.join(output_test_path, pack,
                                           "test_fakefield.html"))
    #write_output(output_test_path, pack, "test_fakefield.html", rendered)

    assert parse_html(attempted) == parse_html(rendered)


def test_inlinefield(output_test_path, render_output, rendered_template,
                     helper, client):

    form = BasicInputForm()