#NEWLINE# def test_badge_awarded_on_content_percent( self ) : #NEWLINE# #INDENT# 'A badge should be awarded upon 250 words worth of guestbook posts\n        created, but the tracking is done via percentage' #NEWLINE# user = self . _get_user ( ) #NEWLINE# b = get_badge ( '250-words-by-percent' ) #NEWLINE# GuestbookEntry . objects . create ( creator = user , message = 'A few words to start' ) #NEWLINE# ok_ ( ( not b . is_awarded_to ( user ) ) ) #NEWLINE# eq_ ( ( ( 5.0 / 250.0 ) * 100.0 ) , b . progress_for ( user ) . percent ) #NEWLINE# GuestbookEntry . objects . create ( creator = user , message = 'A few more words posted' ) #NEWLINE# ok_ ( ( not b . is_awarded_to ( user ) ) ) #NEWLINE# eq_ ( ( ( 10.0 / 250.0 ) * 100.0 ) , b . progress_for ( user ) . percent ) #NEWLINE# msg = ' ' . join ( ( 'lots of words that repeat' for x in range ( 18 ) ) ) #NEWLINE# GuestbookEntry . objects . create ( creator = user , message = msg ) #NEWLINE# ok_ ( ( not b . is_awarded_to ( user ) ) ) #NEWLINE# eq_ ( ( ( 100.0 / 250.0 ) * 100.0 ) , b . progress_for ( user ) . percent ) #NEWLINE# msg = ' ' . join ( ( 'lots of words that repeat' for x in range ( 30 ) ) ) #NEWLINE# GuestbookEntry . objects . create ( creator = user , message = msg ) #NEWLINE# ok_ ( b . is_awarded_to ( user ) ) #NEWLINE# eq_ ( 0 , b . progress_for ( user ) . percent ) #NEWLINE# eq_ ( 0 , Progress . objects . filter ( user = user , badge = b ) . count ( ) )