#NEWLINE# def test_event_form( self ) : #NEWLINE# #INDENT# now = datetime . datetime . now ( ) #NEWLINE# data = { #NEWLINE# #INDENT# 'start_0' : now . strftime ( '%Y-%m-%d' ) , #NEWLINE# 'start_1' : '00:00' , #NEWLINE# 'end_0' : ( now + datetime . timedelta ( days = 1 ) ) . strftime ( '%Y-%m-%d' ) , #NEWLINE# 'end_1' : '00:00' , #NEWLINE# 'title' : 'some title' , #NEWLINE# #UNINDENT# } #NEWLINE# form = EventForm ( data = data ) #NEWLINE# validated = form . is_valid ( ) #NEWLINE# self . assertTrue ( validated ) #NEWLINE# data [ 'end_0' ] = ( now - datetime . timedelta ( days = 1 ) ) . strftime ( '%Y-%m-%d' ) #NEWLINE# form = EventForm ( data = data ) #NEWLINE# validated = form . is_valid ( ) #NEWLINE# self . assertFalse ( validated ) #NEWLINE# self . assertEqual ( len ( form . non_field_errors ( ) ) , 1 ) #NEWLINE# self . assertEqual ( form . non_field_errors ( ) [ 0 ] , 'The end time must be later than start time.' ) #NEWLINE# del data [ 'end_0' ] #NEWLINE# del data [ 'end_1' ] #NEWLINE# del data [ 'start_0' ] #NEWLINE# del data [ 'start_1' ] #NEWLINE# form = EventForm ( data = data ) #NEWLINE# validated = form . is_valid ( ) #NEWLINE# self . assertFalse ( validated ) #NEWLINE# self . assertEqual ( len ( form . non_field_errors ( ) ) , 0 ) #NEWLINE# self . assertEqual ( len ( form . errors ) , 2 ) #NEWLINE# self . assertEqual ( len ( form . errors [ 'end' ] ) , 1 ) #NEWLINE# self . assertEqual ( form . errors [ 'end' ] [ 0 ] , 'This field is required.' ) #NEWLINE# self . assertEqual ( len ( form . errors [ 'start' ] ) , 1 ) #NEWLINE# self . assertEqual ( form . errors [ 'start' ] [ 0 ] , 'This field is required.' )