#NEWLINE# def test_create( self ) : #NEWLINE# #INDENT# 'Can create badge with form' #NEWLINE# r = self . client . get ( reverse ( 'badger.views.create' ) ) #NEWLINE# eq_ ( 302 , r . status_code ) #NEWLINE# ok_ ( ( '/accounts/login' in r [ 'Location' ] ) ) #NEWLINE# settings . BADGER_ALLOW_ADD_BY_ANYONE = True #NEWLINE# self . client . login ( username = 'tester' , password = 'trustno1' ) #NEWLINE# r = self . client . get ( reverse ( 'badger.views.create' ) ) #NEWLINE# eq_ ( 200 , r . status_code ) #NEWLINE# doc = pq ( r . content ) #NEWLINE# form = doc ( 'form#create_badge' ) #NEWLINE# eq_ ( 1 , form . length ) #NEWLINE# eq_ ( 1 , form . find ( 'input[name=title]' ) . length ) #NEWLINE# eq_ ( 1 , form . find ( 'textarea[name=description]' ) . length ) #NEWLINE# eq_ ( 1 , form . find ( 'input.submit,button.submit' ) . length ) #NEWLINE# r = self . client . post ( reverse ( 'badger.views.create' ) , dict ( ) , follow = True ) #NEWLINE# doc = pq ( r . content ) #NEWLINE# eq_ ( 1 , doc . find ( 'form .error > input[name=title]' ) . length ) #NEWLINE# badge_title = 'Test badge #1' #NEWLINE# badge_desc = 'This is a test badge' #NEWLINE# r = self . client . post ( reverse ( 'badger.views.create' ) , dict ( title = badge_title , description = badge_desc ) , follow = True ) #NEWLINE# doc = pq ( r . content ) #NEWLINE# eq_ ( 'badge_detail' , doc . find ( 'body' ) . attr ( 'id' ) ) #NEWLINE# ok_ ( ( badge_title in doc . find ( '.badge .title' ) . text ( ) ) ) #NEWLINE# eq_ ( badge_desc , doc . find ( '.badge .description' ) . text ( ) ) #NEWLINE# slug = doc . find ( '.badge' ) . attr ( 'data-slug' ) #NEWLINE# badge = Badge . objects . get ( slug = slug ) #NEWLINE# eq_ ( badge_title , badge . title ) #NEWLINE# eq_ ( badge_desc , badge . description )