#NEWLINE# def test_delete_period( self ) : #NEWLINE# #INDENT# 'Test for the ``delete_period`` function.' #NEWLINE# occurrence = mixer . blend ( 'calendarium.Occurrence' ) #NEWLINE# occurrence . delete_period ( 'all' ) #NEWLINE# self . assertEqual ( Occurrence . objects . all ( ) . count ( ) , 0 , msg = 'Should delete only the first occurrence.' ) #NEWLINE# event = mixer . blend ( 'calendarium.Event' , start = ( now ( ) - timedelta ( hours = 0 ) ) , end = ( now ( ) - timedelta ( hours = 0 ) ) ) #NEWLINE# occurrence = mixer . blend ( 'calendarium.Occurrence' , event = event , start = ( now ( ) - timedelta ( hours = 0 ) ) , end = ( now ( ) - timedelta ( hours = 0 ) ) ) #NEWLINE# occurrence . delete_period ( 'this one' ) #NEWLINE# self . assertEqual ( Occurrence . objects . all ( ) . count ( ) , 0 , msg = 'Should delete only the first occurrence.' ) #NEWLINE# event = mixer . blend ( 'calendarium.Event' , start = ( now ( ) - timedelta ( hours = 0 ) ) , end = ( now ( ) - timedelta ( hours = 0 ) ) ) #NEWLINE# event . save ( ) #NEWLINE# occurrence = mixer . blend ( 'calendarium.Occurrence' , event = event , start = ( now ( ) - timedelta ( hours = 0 ) ) , end = ( now ( ) - timedelta ( hours = 0 ) ) ) #NEWLINE# occurrence . delete_period ( 'following' ) #NEWLINE# self . assertEqual ( Event . objects . all ( ) . count ( ) , 0 , msg = 'Should delete the event and the occurrence.' ) #NEWLINE# occurrence_1 = mixer . blend ( 'calendarium.Occurrence' , start = now ( ) , end = ( now ( ) + timedelta ( days = 1 ) ) , original_start = ( now ( ) + timedelta ( hours = 1 ) ) ) #NEWLINE# occurrence_2 = mixer . blend ( 'calendarium.Occurrence' , start = now ( ) , end = ( now ( ) + timedelta ( days = 1 ) ) , original_start = ( now ( ) + timedelta ( hours = 1 ) ) ) #NEWLINE# occurrence_2 . event = occurrence_1 . event #NEWLINE# occurrence_2 . save ( ) #NEWLINE# occurrence_2 . delete_period ( 'this one' ) #NEWLINE# occurrence_3 = mixer . blend ( 'calendarium.Occurrence' , start = now ( ) , end = ( now ( ) + timedelta ( days = 1 ) ) , original_start = ( now ( ) + timedelta ( hours = 1 ) ) ) #NEWLINE# occurrence_3 . event = occurrence_1 . event #NEWLINE# occurrence_3 . save ( ) #NEWLINE# occurrence_4 = mixer . blend ( 'calendarium.Occurrence' , start = now ( ) , end = ( now ( ) + timedelta ( days = 1 ) ) , original_start = ( now ( ) + timedelta ( hours = 1 ) ) ) #NEWLINE# occurrence_4 . event = occurrence_1 . event #NEWLINE# occurrence_4 . save ( ) #NEWLINE# occurrence_3 . delete_period ( 'this one' ) #NEWLINE# occurrence_1 . delete_period ( 'following' ) #NEWLINE# self . assertEqual ( Occurrence . objects . all ( ) . count ( ) , 0 , msg = 'Should delete all occurrences with this start date.' )