def testHtmlBody_WithEscapedHtml(self): """"An html body is sent with html content escaped.""" body_with_html_content = ( '<a href="http://www.google.com">test</a> \'something\'') email_task = notify_helpers._MakeEmailWorkItem( notify_reasons.AddrPerm(False, '*****@*****.**', self.member, REPLY_NOT_ALLOWED, user_pb2.UserPrefs()), ['reason'], self.issue, 'body link-only', body_with_html_content, 'unused body mem', self.project, 'example.com', self.commenter_view, self.detail_url) escaped_body_with_html_content = ( '<a href="http://www.google.com">test</a> ' ''something'') notify_helpers._MakeNotificationFooter(['reason'], REPLY_NOT_ALLOWED, 'example.com') expected_html_body = ( notify_helpers.HTML_BODY_WITH_GMAIL_ACTION_TEMPLATE % { 'url': self.detail_url, 'body': '%s-- <br/>%s' % (escaped_body_with_html_content, self.expected_html_footer) }) self.assertEquals(expected_html_body, email_task['html_body'])
def testMakeNotificationFooter_WithReason(self): footer = notify_helpers._MakeNotificationFooter(['REASON'], REPLY_NOT_ALLOWED, 'example.com') self.assertIn('REASON', footer) self.assertIn('https://example.com/hosting/settings', footer) footer = notify_helpers._MakeNotificationFooter(['REASON'], REPLY_NOT_ALLOWED, 'example.com') self.assertIn('REASON', footer) self.assertIn('https://example.com/hosting/settings', footer)
def testMakeNotificationFooter_ManyReasons(self): footer = notify_helpers._MakeNotificationFooter( ['Funny', 'Caring', 'Warmblooded'], REPLY_NOT_ALLOWED, 'example.com') self.assertIn('Funny', footer) self.assertIn('Caring', footer) self.assertIn('Warmblooded', footer)
def testMakeNotificationFooter_WithReplyInstructions(self): footer = notify_helpers._MakeNotificationFooter(['REASON'], REPLY_NOT_ALLOWED, 'example.com') self.assertNotIn('Reply', footer) self.assertIn('https://example.com/hosting/settings', footer) footer = notify_helpers._MakeNotificationFooter(['REASON'], REPLY_MAY_COMMENT, 'example.com') self.assertIn('add a comment', footer) self.assertNotIn('make updates', footer) self.assertIn('https://example.com/hosting/settings', footer) footer = notify_helpers._MakeNotificationFooter(['REASON'], REPLY_MAY_UPDATE, 'example.com') self.assertIn('add a comment', footer) self.assertIn('make updates', footer) self.assertIn('https://example.com/hosting/settings', footer)
def testMakeNotificationFooter_NoReason(self): footer = notify_helpers._MakeNotificationFooter([], REPLY_NOT_ALLOWED, 'example.com') self.assertEqual('', footer)