#NEWLINE# def test_record_of_sent_email_is_written_to_datastore( self ) : #NEWLINE# #INDENT# with self . swap ( feconf , 'CAN_SEND_EMAILS_TO_USERS' , True ) : #NEWLINE# #INDENT# config_services . set_property ( self . admin_id , email_manager . EMAIL_FOOTER . name , self . new_footer ) #NEWLINE# config_services . set_property ( self . admin_id , email_manager . SIGNUP_EMAIL_CONTENT . name , self . new_email_content ) #NEWLINE# config_services . set_property ( self . admin_id , email_manager . EMAIL_SENDER_NAME . name , 'Email Sender' ) #NEWLINE# all_models = email_models . SentEmailModel . get_all ( ) . fetch ( ) #NEWLINE# self . assertEqual ( len ( all_models ) , 0 ) #NEWLINE# self . login ( self . EDITOR_EMAIL ) #NEWLINE# response = self . testapp . get ( feconf . SIGNUP_URL ) #NEWLINE# csrf_token = self . get_csrf_token_from_response ( response ) #NEWLINE# self . post_json ( feconf . SIGNUP_DATA_URL , { #NEWLINE# #INDENT# 'agreed_to_terms' : True , #NEWLINE# 'username' : self . EDITOR_USERNAME , #NEWLINE# #UNINDENT# } , csrf_token = csrf_token ) #NEWLINE# messages = self . mail_stub . get_sent_messages ( to = self . EDITOR_EMAIL ) #NEWLINE# self . assertEqual ( 1 , len ( messages ) ) #NEWLINE# all_models = email_models . SentEmailModel . get_all ( ) . fetch ( ) #NEWLINE# self . assertEqual ( len ( self ) , 1 ) #NEWLINE# sent_email_model = all_models [ 0 ] #NEWLINE# self . assertEqual ( sent_email_model . recipient_id , self . get_user_id_from_email ( self . EDITOR_EMAIL ) ) #NEWLINE# self . assertEqual ( sent_email_model . recipient_email , self . EDITOR_EMAIL ) #NEWLINE# self . assertEqual ( sent_email_model . sender_id , feconf . SYSTEM_COMMITTER_ID ) #NEWLINE# self . assertEqual ( sent_email_model . sender_email , ( 'Email Sender <%s>' % feconf . SYSTEM_EMAIL_ADDRESS ) ) #NEWLINE# self . assertEqual ( sent_email_model . intent , feconf . EMAIL_INTENT_SIGNUP ) #NEWLINE# self . assertEqual ( sent_email_model . subject , 'Welcome!' ) #NEWLINE# self . assertEqual ( sent_email_model . html_body , self . expected_html_email_content )