#NEWLINE# def test_hashes_get_generated( self ) : #NEWLINE# #INDENT# def _generate_hash_for_tests( cls , recipient_id , email_subject , email_body ) : #NEWLINE# #INDENT# if ( recipient_id == 'recipient_id1' ) : #NEWLINE# #INDENT# return None #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( recipient_id == 'recipient_id2' ) : #NEWLINE# #INDENT# return '' #NEWLINE# #UNINDENT# #UNINDENT# return 'Email Hash' #NEWLINE# #UNINDENT# generate_constant_hash_ctx = self . swap ( email_models . SentEmailModel , '_generate_hash' , types . MethodType ( _generate_hash_for_tests , email_models . SentEmailModel ) ) #NEWLINE# with generate_constant_hash_ctx : #NEWLINE# #INDENT# email_models . SentEmailModel . create ( 'recipient_id1' , 'recipient@email.com' , 'sender_id' , 'sender@email.com' , feconf . EMAIL_INTENT_SIGNUP , 'Email Subject' , 'Email Body' , datetime . datetime . utcnow ( ) ) #NEWLINE# email_models . SentEmailModel . create ( 'recipient_id2' , 'recipient@email.com' , 'sender_id' , 'sender@email.com' , feconf . EMAIL_INTENT_SIGNUP , 'Email Subject' , 'Email Body' , datetime . datetime . utcnow ( ) ) #NEWLINE# email_models . SentEmailModel . create ( 'recipient_id3' , 'recipient@email.com' , 'sender_id' , 'sender@email.com' , feconf . EMAIL_INTENT_SIGNUP , 'Email Subject' , 'Email Body' , datetime . datetime . utcnow ( ) ) #NEWLINE# #UNINDENT# all_models = email_models . SentEmailModel . get_all ( ) . fetch ( ) #NEWLINE# self . assertEqual ( len ( all_models ) , 3 ) #NEWLINE# for model in all_models : #NEWLINE# #INDENT# if ( model . recipient_id == 'recipient_id1' ) : #NEWLINE# #INDENT# self . assertIsNone ( model . email_hash ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( model . recipient_id == 'recipient_id2' ) : #NEWLINE# #INDENT# self . assertEqual ( len ( model . email_hash ) , 0 ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# self . _run_one_off_job ( ) #NEWLINE# all_models = email_models . SentEmailModel . get_all ( ) . fetch ( ) #NEWLINE# self . assertEqual ( len ( all_models ) , 3 ) #NEWLINE# all_models = email_models . SentEmailModel . get_all ( ) . fetch ( ) #NEWLINE# for model in all_models : #NEWLINE# #INDENT# self . assertIsNotNone ( model . email_hash )