def test_email_posting_disabled(self): message = 'Hello, world!' import forgetracker c.user = M.User.by_username('test-admin') with mock.patch.object(forgetracker.tracker_main.ForgeTrackerApp, 'handle_message') as hm: c.app.config.options = {'AllowEmailPosting': False} mail_tasks.route_email('0.0.0.0', c.user.email_addresses[0], ['*****@*****.**'], message) assert_equal(hm.call_count, 0)
def test_receive_email_ok(self): c.user = M.User.by_username('test-admin') import forgewiki with mock.patch.object(forgewiki.wiki_main.ForgeWikiApp, 'handle_message') as f: mail_tasks.route_email('0.0.0.0', c.user.email_addresses[0], ['*****@*****.**'], 'This is a mail message') args, kwargs = f.call_args assert args[0] == 'Page' assert len(args) == 2
def _post_email(self, mailfrom, rcpttos, subject, msg): '''msg is MIME message object''' msg['Message-ID'] = '<' + h.gen_message_id() + '>' msg['From'] = mailfrom msg['To'] = ', '.join(rcpttos) msg['Subject'] = subject mail_tasks.route_email(peer='127.0.0.1', mailfrom=mailfrom, rcpttos=rcpttos, data=msg.as_string()) M.artifact_orm_session.flush()
def test_receive_email_ok(self): c.user = M.User.by_username('test-admin') import forgewiki with mock.patch.object(forgewiki.wiki_main.ForgeWikiApp, 'handle_message') as f: mail_tasks.route_email( '0.0.0.0', c.user.email_addresses[0], ['*****@*****.**'], 'This is a mail message') args, kwargs = f.call_args assert args[0] == 'Page' assert len(args) == 2
def test_email_posting_disabled(self): message = 'Hello, world!' import forgetracker c.user = M.User.by_username('test-admin') with mock.patch.object(forgetracker.tracker_main.ForgeTrackerApp, 'handle_message') as hm: c.app.config.options = {'AllowEmailPosting': False} mail_tasks.route_email( '0.0.0.0', c.user.email_addresses[0], ['*****@*****.**'], message) assert_equal(hm.call_count, 0)
def _post_email(self, mailfrom, rcpttos, subject, msg): '''msg is MIME message object''' msg['Message-ID'] = '<' + h.gen_message_id() + '>' msg['From'] = mailfrom msg['To'] = ', '.join(rcpttos) msg['Subject'] = subject mail_tasks.route_email( peer='127.0.0.1', mailfrom=mailfrom, rcpttos=rcpttos, data=msg.as_string()) M.artifact_orm_session.flush()
def test_receive_autoresponse(self): message = '''Date: Wed, 30 Oct 2013 01:38:40 -0700 From: <*****@*****.**> To: <*****@*****.**> Message-ID: <super-unique-id> Subject: Not here Re: Message notification Precedence: bulk X-Autoreply: yes Auto-Submitted: auto-replied I'm not here''' import forgetracker c.user = M.User.by_username('test-admin') with mock.patch.object(forgetracker.tracker_main.ForgeTrackerApp, 'handle_message') as hm: mail_tasks.route_email('0.0.0.0', c.user.email_addresses[0], ['*****@*****.**'], message) assert_equal(hm.call_count, 0)
def test_receive_autoresponse(self): message = '''Date: Wed, 30 Oct 2013 01:38:40 -0700 From: <*****@*****.**> To: <*****@*****.**> Message-ID: <super-unique-id> Subject: Not here Re: Message notification Precedence: bulk X-Autoreply: yes Auto-Submitted: auto-replied I'm not here''' import forgetracker c.user = M.User.by_username('test-admin') with mock.patch.object(forgetracker.tracker_main.ForgeTrackerApp, 'handle_message') as hm: mail_tasks.route_email( '0.0.0.0', c.user.email_addresses[0], ['*****@*****.**'], message) assert_equal(hm.call_count, 0)