<s> from django . core . exceptions import ValidationError <EOL> from django . test import TestCase <EOL> from django . utils import six <EOL> from django . utils . functional import lazy <EOL> from fancy_cronfield . fields import CronField <EOL> from fancy_cronfield . utils . compat import DJANGO_1_6 , DJANGO_1_5 <EOL> from fancy_cronfield . widgets import CronWidget <EOL> class CronFieldTests ( TestCase ) : <EOL> def test_get_internal_type ( self ) : <EOL> field = CronField ( ) <EOL> self . assertEqual ( field . get_internal_type ( ) , '<STR_LIT>' ) <EOL> def test_to_python ( self ) : <EOL> field = CronField ( ) <EOL> self . assertEqual ( field . to_python ( '<STR_LIT>' ) , '<STR_LIT>' ) <EOL> def test_get_prep_value ( self ) : <EOL> field = CronField ( ) <EOL> if DJANGO_1_5 or DJANGO_1_6 : <EOL> value = field . get_prep_value ( six . text_type ( '<STR_LIT>' ) ) <EOL> else : <EOL> lazy_func = lazy ( lambda : u'<STR_LIT>' , six . text_type ) <EOL> value = field . get_prep_value ( lazy_func ( ) ) <EOL> self . assertIsInstance ( value , six . string_types ) <EOL> def test_get_prep_value_int ( self ) : <EOL> field = CronField ( ) <EOL> if DJANGO_1_5 or DJANGO_1_6 : <EOL> value = field . get_prep_value ( int ( <NUM_LIT:0> ) ) <EOL> else : <EOL> lazy_func = lazy ( lambda : <NUM_LIT:0> , int ) <EOL> value = field . get_prep_value ( lazy_func ( ) ) <EOL> self . assertIsInstance ( value , six . text_type ) <EOL> def test_max_length_passed_to_formfield ( self ) : <EOL> """<STR_LIT>""" <EOL> cf1 = CronField ( ) <EOL> cf2 = CronField ( max_length = <NUM_LIT> ) <EOL> self . assertEqual ( cf1 . formfield ( ) . max_length , <NUM_LIT> ) <EOL> self . assertEqual ( cf2 . formfield ( ) . max_length , <NUM_LIT> ) <EOL> def test_widget_passed_to_formfield ( self ) : <EOL> f = CronField ( ) <EOL> self . assertEqual ( f . formfield ( ) . widget . __class__ , CronWidget ) <EOL> def test_raises_error_on_empty_string ( self ) : <EOL> f = CronField ( ) <EOL> self . assertRaises ( ValidationError , f . clean , "<STR_LIT>" , None ) <EOL> def test_cleans_empty_string_when_blank_true ( self ) : <EOL> f = CronField ( blank = True ) <EOL> self . assertEqual ( '<STR_LIT>' , f . clean ( '<STR_LIT>' , None ) ) <EOL> def test_raises_error_on_invalid_input ( self ) : <EOL> f = CronField ( ) <EOL> self . assertRaises ( ValidationError , f . clean , '<STR_LIT:test>' , None ) <EOL> def test_raises_error_on_empty_input ( self ) : <EOL> f = CronField ( null = False ) <EOL> self . assertRaises ( ValidationError , f . clean , None , None ) </s>
