<s> import unittest <EOL> from django import forms <EOL> from django_genericfilters import forms as gf <EOL> class FormTestCase ( unittest . TestCase ) : <EOL> def test_query_form_mixin ( self ) : <EOL> class Form ( gf . QueryFormMixin , forms . Form ) : <EOL> pass <EOL> form = Form ( ) <EOL> self . assertTrue ( '<STR_LIT>' in form . fields ) <EOL> def test_order_form_mixin ( self ) : <EOL> def get_order_by_choices ( ) : <EOL> return ( ( '<STR_LIT>' , '<STR_LIT>' ) , <EOL> ( '<STR_LIT>' , '<STR_LIT>' ) ) <EOL> class Form ( gf . OrderFormMixin , forms . Form ) : <EOL> def get_order_by_choices ( self ) : <EOL> return get_order_by_choices ( ) <EOL> form = Form ( ) <EOL> self . assertTrue ( '<STR_LIT>' in form . fields ) <EOL> self . assertTrue ( '<STR_LIT>' in form . fields ) <EOL> self . assertEqual ( form . fields [ '<STR_LIT>' ] . choices , <EOL> list ( get_order_by_choices ( ) ) ) <EOL> def test_get_order_by_choices_not_implemented ( self ) : <EOL> class Form ( gf . OrderFormMixin ) : <EOL> pass <EOL> self . assertRaises ( NotImplementedError , Form ) <EOL> class FilteredFormTestCase ( unittest . TestCase ) : <EOL> class Form ( gf . FilteredForm ) : <EOL> def get_order_by_choices ( self ) : <EOL> return ( ( '<STR_LIT>' , '<STR_LIT>' ) , <EOL> ( '<STR_LIT>' , '<STR_LIT>' ) ) <EOL> def test_empty_form_bound ( self ) : <EOL> form = self . Form ( data = { } , initial = { "<STR_LIT>" : '<STR_LIT>' } ) <EOL> self . assertTrue ( form . is_bound ) <EOL> self . assertTrue ( form . is_valid ( ) ) <EOL> self . assertEqual ( form . cleaned_data [ '<STR_LIT>' ] , '<STR_LIT>' ) <EOL> def test_form_order_by_bound ( self ) : <EOL> form = self . Form ( data = { '<STR_LIT>' : '<STR_LIT>' , '<STR_LIT>' : <NUM_LIT:0> } , <EOL> initial = { "<STR_LIT>" : '<STR_LIT>' } ) <EOL> self . assertTrue ( form . is_bound ) <EOL> self . assertTrue ( form . is_valid ( ) ) <EOL> self . assertEqual ( form . cleaned_data [ '<STR_LIT>' ] , '<STR_LIT>' ) <EOL> def test_filtered_form ( self ) : <EOL> form = self . Form ( ) <EOL> self . assertEqual ( str ( type ( form . fields [ '<STR_LIT>' ] . widget ) ) , <EOL> "<STR_LIT>" ) <EOL> self . assertEqual ( str ( type ( form . fields [ '<STR_LIT>' ] . widget ) ) , <EOL> "<STR_LIT>" ) <EOL> self . assertEqual ( str ( type ( form . fields [ '<STR_LIT>' ] . widget ) ) , <EOL> "<STR_LIT>" ) </s>
