#NEWLINE# @ attr ( 'json' ) #NEWLINE# def test_award_detail( self ) : #NEWLINE# #INDENT# 'Can view award detail' #NEWLINE# user = self . _get_user ( ) #NEWLINE# user2 = self . _get_user ( username = 'tester2' ) #NEWLINE# ( b1 , created ) = Badge . objects . get_or_create ( creator = user , title = 'Code Badge #1' , description = 'Some description' ) #NEWLINE# award = b1 . award_to ( user2 ) #NEWLINE# url = reverse ( 'badger.views.award_detail' , args = ( b1 . slug , award . pk ) ) #NEWLINE# r = self . client . get ( url , follow = True ) #NEWLINE# doc = pq ( r . content ) #NEWLINE# eq_ ( 'award_detail' , doc . find ( 'body' ) . attr ( 'id' ) ) #NEWLINE# eq_ ( 1 , doc . find ( ( '.award .awarded_to .username:contains("%s")' % user2 . username ) ) . length ) #NEWLINE# eq_ ( 1 , doc . find ( ( '.badge .title:contains("%s")' % b1 . title ) ) . length ) #NEWLINE# url = reverse ( 'badger.award_detail_json' , args = ( b1 . slug , award . pk ) ) #NEWLINE# r = self . client . get ( url , follow = True ) #NEWLINE# data = json . loads ( r . content ) #NEWLINE# hash_salt = hashlib . md5 ( ( '%s-%s' % ( award . badge . pk , award . pk ) ) ) . hexdigest ( ) #NEWLINE# recipient_text = ( '%s%s' % ( award . user . email , hash_salt ) ) #NEWLINE# recipient_hash = ( 'sha256$%s' % hashlib . sha256 ( recipient_text ) . hexdigest ( ) ) #NEWLINE# eq_ ( recipient_hash , data [ 'recipient' ] ) #NEWLINE# eq_ ( ( 'http://testserver%s' % award . get_absolute_url ( ) ) , data [ 'evidence' ] ) #NEWLINE# eq_ ( award . badge . title , data [ 'badge' ] [ 'name' ] ) #NEWLINE# eq_ ( award . badge . description , data [ 'badge' ] [ 'description' ] ) #NEWLINE# eq_ ( ( 'http://testserver%s' % award . badge . get_absolute_url ( ) ) , data [ 'badge' ] [ 'criteria' ] )