#NEWLINE# def test_handle_complaint( self ) : #NEWLINE# #INDENT# '\n        Test handling a normal complaint request.\n        ' #NEWLINE# req_mail_obj = { #NEWLINE# #INDENT# 'timestamp' : '2012-05-25T14:59:38.623-07:00' , #NEWLINE# 'messageId' : '000001378603177f-7a5433e7-8edb-42ae-af10-f0181f34d6ee-000000' , #NEWLINE# 'source' : 'sender@example.com' , #NEWLINE# 'destination' : [ 'recipient1@example.com' , 'recipient2@example.com' , 'recipient3@example.com' , 'recipient4@example.com' ] , #NEWLINE# #UNINDENT# } #NEWLINE# req_complaint_obj = { #NEWLINE# #INDENT# 'userAgent' : 'Comcast Feedback Loop (V0.01)' , #NEWLINE# 'complainedRecipients' : [ { #NEWLINE# #INDENT# 'emailAddress' : 'recipient1@example.com' , #NEWLINE# #UNINDENT# } ] , #NEWLINE# 'complaintFeedbackType' : 'abuse' , #NEWLINE# 'arrivalDate' : '2009-12-03T04:24:21.000-05:00' , #NEWLINE# 'timestamp' : '2012-05-25T14:59:38.623-07:00' , #NEWLINE# 'feedbackId' : '000001378603177f-18c07c78-fa81-4a58-9dd1-fedc3cb8f49a-000000' , #NEWLINE# #UNINDENT# } #NEWLINE# message_obj = { #NEWLINE# #INDENT# 'notificationType' : 'Complaint' , #NEWLINE# 'mail' : req_mail_obj , #NEWLINE# 'complaint' : self , #NEWLINE# #UNINDENT# } #NEWLINE# notification = { #NEWLINE# #INDENT# 'Type' : 'Notification' , #NEWLINE# 'MessageId' : '22b80b92-fdea-4c2c-8f9d-bdfb0c7bf324' , #NEWLINE# 'TopicArn' : 'arn:aws:sns:us-east-1:123456789012:MyTopic' , #NEWLINE# 'Subject' : 'AWS Notification Message' , #NEWLINE# 'Message' : json . dumps ( message_obj ) , #NEWLINE# 'Timestamp' : '2012-05-02T00:54:06.655Z' , #NEWLINE# 'SignatureVersion' : '1' , #NEWLINE# 'Signature' : '' , #NEWLINE# 'SigningCertURL' : '' , #NEWLINE# 'UnsubscribeURL' : '' , #NEWLINE# #UNINDENT# } #NEWLINE# def _handler( sender , mail_obj , complaint_obj , **kwargs ) : #NEWLINE# #INDENT# _handler . called = True #NEWLINE# self . assertEquals ( req_mail_obj , mail_obj ) #NEWLINE# self . assertEquals ( req_complaint_obj , complaint_obj ) #NEWLINE# #UNINDENT# _handler . called = False #NEWLINE# complaint_received . connect ( _handler ) #NEWLINE# with mock . patch . object ( ses_utils , 'verify_bounce_message' ) as verify : #NEWLINE# #INDENT# verify . return_value = True #NEWLINE# self . client . post ( reverse ( 'django_ses_bounce' ) , json . dumps ( notification ) , content_type = 'application/json' ) #NEWLINE# #UNINDENT# self . assertTrue ( _handler . called )