# Path: boards/templatetags/form_tags.py
# @register.filter
# def field_type(bound_field):
#     return bound_field.field.widget.__class__.__name__
# 
# @register.filter
# def input_class(bound_field):
#     css_class = ''
#     if bound_field.form.is_bound:
#         if bound_field.errors:
#             css_class = 'is-invalid'
#         elif field_type(bound_field) != 'PasswordInput':
#             css_class = 'is-valid'
#     return 'form-control {}'.format(css_class)


from django import forms
from django.test import TestCase
from ..templatetags.form_tags import field_type, input_class



class ExampleForm(forms.Form):
    name = forms.CharField()
    password = forms.CharField(widget=forms.PasswordInput())

    class Meta:
        fields = ('name', 'password')


class FieldTypeTests(TestCase):
    def test_field_widget_type(self):
        form = ExampleForm()
        self.assertEquals('TextInput', field_type(form['name']))

# Path: boards/templatetags/form_tags.py
# @register.filter
# def field_type(bound_field):
#     return bound_field.field.widget.__class__.__name__
# 
# @register.filter
# def input_class(bound_field):
#     css_class = ''
#     if bound_field.form.is_bound:
#         if bound_field.errors:
#             css_class = 'is-invalid'
#         elif field_type(bound_field) != 'PasswordInput':
#             css_class = 'is-valid'
#     return 'form-control {}'.format(css_class)


# Path: boards/tests/test_templatetags.py
from django import forms
from django.test import TestCase
from ..templatetags.form_tags import field_type, input_class




class ExampleForm(forms.Form):
    name = forms.CharField()
    password = forms.CharField(widget=forms.PasswordInput())

    class Meta:
        fields = ('name', 'password')


class FieldTypeTests(TestCase):
    def test_field_widget_type(self):
        form = ExampleForm()
        self.assertEquals('TextInput', field_type(form['name']))

        self.assertEquals('PasswordInput', field_type(form['password']))