# Path: crispy_forms_foundation/layout/base.py
# class Layout(crispy_forms_layout.Layout):
#     pass
# 
# Path: crispy_forms_foundation/layout/grid.py
# class Row(Div):
#     """
#     Wrap fields in a div whose default class is ``row``. Example:
# 
#     .. sourcecode:: python
# 
#         Row('form_field_1', 'form_field_2', 'form_field_3')
# 
#     Act as a div container row, it will embed its items in a div like that:
# 
#     .. sourcecode:: html
# 
#         <div class"row">Content</div>
#     """
#     css_class = 'row'
# 
# class Column(Div):
#     """
#     Wrap fields in a div. If not defined, CSS class will default to
#     ``large-12 columns``. ``columns`` class is always appended, so you don't
#     need to specify it.
# 
#     This is the column from the Foundation Grid component, all columns should
#     be contained in a **Row** or a **RowFluid** and you will have to define the
#     column type in the ``css_class`` attribute.
# 
#     Example:
# 
#     .. sourcecode:: python
# 
#         Column('form_field_1', 'form_field_2', css_class='small-12 large-6')
# 
#     Will render to something like that:
# 
#     .. sourcecode:: html
# 
#         <div class"small-12 large-6 columns">...</div>
# 
#     ``columns`` class is always appended, so you don't need to specify it.
# 
#     If not defined, ``css_class`` will default to ``large-12``.
#     """
#     css_class = 'columns'
# 
#     def __init__(self, field, *args, **kwargs):
#         self.field = field
#         if 'css_class' not in kwargs:
#             kwargs['css_class'] = 'large-12'
# 
#         super(Column, self).__init__(field, *args, **kwargs)
# 
# Path: crispy_forms_foundation/layout/buttons.py
# class ButtonHolder(crispy_forms_layout.ButtonHolder):
#     """
#     It wraps fields in an element ``<div class="button-holder">``.
# 
#     This is where you should put Layout objects that render to form buttons
#     like Submit. It should only hold ``HTML`` and ``BaseInput`` inherited
#     objects.
# 
#     Example:
# 
#     .. sourcecode:: python
# 
#         ButtonHolder(
#             HTML(<span style="display: hidden;">Information Saved</span>),
#             Submit('Save', 'Save')
#         )
#     """
#     template = "%s/layout/buttonholder.html"
# 
# class Submit(InputSubmit):
#     """
#     This is the old Button object that inherit from ``InputSubmit`` for
#     backward compatibility.
# 
#     If you want to stand for an input button, you are invited to use
#     ``InputSubmit`` instead to avoid problem when ``ButtonSubmit`` will
#     become the new ``Submit`` object.
#     """
#     pass
# 
# 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 BasicInputFormLayoutIncluded(BasicInputForm):
#     """
#     Basic form with included layout
#     """
#     def __init__(self, *args, **kwargs):
#         self.helper = kwargs.pop('helper', FormHelper())
# 
#         self.helper.form_action = '.'
# 
#         self.helper.layout = Layout(
#             'simple',
#         )
# 
#         super(BasicInputFormLayoutIncluded, self).__init__(*args, **kwargs)
# 
# class AdvancedForm(forms.Form):
#     """
#     Form with an advanced layout with some inputs
#     """
#     simple = forms.CharField(label='Simple text',
#                              widget=forms.TextInput(attrs={'required':''}),
#                              required=True)
#     opt_in = forms.BooleanField(
#             label="Opt in",
#             widget=forms.CheckboxInput(attrs={'required': ''}),
#             required=True)
#     longtext = forms.CharField(label='Address', required=False,
#                               widget=forms.Textarea(attrs={'rows': 3}))
# 
#     def save(self, commit=True):
#         return


import os
import pytest
from django.test.html import parse_html
from crispy_forms_foundation.layout import (Layout, Row, Column, ButtonHolder,
                                            Submit)
from tests.forms import BasicInputForm, BasicInputFormLayoutIncluded, AdvancedForm


def test_layout(output_test_path, render_output, rendered_template, helper, client):
    form = BasicInputFormLayoutIncluded(helper=helper)
    pack = helper.template_pack

    rendered = rendered_template(form)

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

    assert parse_html(attempted) == parse_html(rendered)


def test_advanced(output_test_path, render_output, rendered_template, helper, client):
    form = AdvancedForm()
    pack = helper.template_pack

    helper.layout = Layout(
        Row(
            Column(
                'simple',
                css_class='six'
            ),
            Column(
                'opt_in',
                css_class='six'
            ),
        ),

# Path: crispy_forms_foundation/layout/base.py
# class Layout(crispy_forms_layout.Layout):
#     pass
# 
# Path: crispy_forms_foundation/layout/grid.py
# class Row(Div):
#     """
#     Wrap fields in a div whose default class is ``row``. Example:
# 
#     .. sourcecode:: python
# 
#         Row('form_field_1', 'form_field_2', 'form_field_3')
# 
#     Act as a div container row, it will embed its items in a div like that:
# 
#     .. sourcecode:: html
# 
#         <div class"row">Content</div>
#     """
#     css_class = 'row'
# 
# class Column(Div):
#     """
#     Wrap fields in a div. If not defined, CSS class will default to
#     ``large-12 columns``. ``columns`` class is always appended, so you don't
#     need to specify it.
# 
#     This is the column from the Foundation Grid component, all columns should
#     be contained in a **Row** or a **RowFluid** and you will have to define the
#     column type in the ``css_class`` attribute.
# 
#     Example:
# 
#     .. sourcecode:: python
# 
#         Column('form_field_1', 'form_field_2', css_class='small-12 large-6')
# 
#     Will render to something like that:
# 
#     .. sourcecode:: html
# 
#         <div class"small-12 large-6 columns">...</div>
# 
#     ``columns`` class is always appended, so you don't need to specify it.
# 
#     If not defined, ``css_class`` will default to ``large-12``.
#     """
#     css_class = 'columns'
# 
#     def __init__(self, field, *args, **kwargs):
#         self.field = field
#         if 'css_class' not in kwargs:
#             kwargs['css_class'] = 'large-12'
# 
#         super(Column, self).__init__(field, *args, **kwargs)
# 
# Path: crispy_forms_foundation/layout/buttons.py
# class ButtonHolder(crispy_forms_layout.ButtonHolder):
#     """
#     It wraps fields in an element ``<div class="button-holder">``.
# 
#     This is where you should put Layout objects that render to form buttons
#     like Submit. It should only hold ``HTML`` and ``BaseInput`` inherited
#     objects.
# 
#     Example:
# 
#     .. sourcecode:: python
# 
#         ButtonHolder(
#             HTML(<span style="display: hidden;">Information Saved</span>),
#             Submit('Save', 'Save')
#         )
#     """
#     template = "%s/layout/buttonholder.html"
# 
# class Submit(InputSubmit):
#     """
#     This is the old Button object that inherit from ``InputSubmit`` for
#     backward compatibility.
# 
#     If you want to stand for an input button, you are invited to use
#     ``InputSubmit`` instead to avoid problem when ``ButtonSubmit`` will
#     become the new ``Submit`` object.
#     """
#     pass
# 
# 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 BasicInputFormLayoutIncluded(BasicInputForm):
#     """
#     Basic form with included layout
#     """
#     def __init__(self, *args, **kwargs):
#         self.helper = kwargs.pop('helper', FormHelper())
# 
#         self.helper.form_action = '.'
# 
#         self.helper.layout = Layout(
#             'simple',
#         )
# 
#         super(BasicInputFormLayoutIncluded, self).__init__(*args, **kwargs)
# 
# class AdvancedForm(forms.Form):
#     """
#     Form with an advanced layout with some inputs
#     """
#     simple = forms.CharField(label='Simple text',
#                              widget=forms.TextInput(attrs={'required':''}),
#                              required=True)
#     opt_in = forms.BooleanField(
#             label="Opt in",
#             widget=forms.CheckboxInput(attrs={'required': ''}),
#             required=True)
#     longtext = forms.CharField(label='Address', required=False,
#                               widget=forms.Textarea(attrs={'rows': 3}))
# 
#     def save(self, commit=True):
#         return


# Path: tests/002_layout.py
import os
import pytest
from django.test.html import parse_html
from crispy_forms_foundation.layout import (Layout, Row, Column, ButtonHolder,
                                            Submit)
from tests.forms import BasicInputForm, BasicInputFormLayoutIncluded, AdvancedForm



def test_layout(output_test_path, render_output, rendered_template, helper, client):
    form = BasicInputFormLayoutIncluded(helper=helper)
    pack = helper.template_pack

    rendered = rendered_template(form)

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

    assert parse_html(attempted) == parse_html(rendered)


def test_advanced(output_test_path, render_output, rendered_template, helper, client):
    form = AdvancedForm()
    pack = helper.template_pack

    helper.layout = Layout(
        Row(
            Column(
                'simple',
                css_class='six'
            ),
            Column(
                'opt_in',
                css_class='six'
            ),
        ),

        Row(