from tests.testclient import JenniferTestClient from tests.testbrain import JenniferTestBrain from lessons.base.responses import JenniferResponse, JenniferTextResponseSegment from lessons.JenniferGmailPlugin.plugin import JenniferGmailPlugin from lessons.JenniferGmailPlugin.logic import GmailImapWrapper from lessons.JenniferGmailPlugin.shared_settings import JenniferGmailSharedSettings @mock.patch.object(GmailImapWrapper, '_get_status', mock_imap_status) @mock.patch.object(GmailImapWrapper, 'login_and_select', mock_imap_do_nothing) @mock.patch.object(GmailImapWrapper, 'logout_and_close', mock_imap_do_nothing) @mock.patch.object(GmailImapWrapper, 'get_unread_emails', mock_imap_get_unread_emails) @mock.patch.object(GmailImapWrapper, 'get_first_text_block', mock_imap_get_first_text_block) @mock.patch.object(JenniferGmailSharedSettings, 'get_accounts', test_get_gmail_accounts()) class JenniferGmailPluginTests(unittest.TestCase): def setUp(self): self.brain = JenniferTestBrain(always_allow_plugins=[JenniferGmailPlugin]) self.brain.disable_unsure_response() def test_counting(self): inputs = [ "count unread emails" ] client = JenniferTestClient(self.brain, inputs) client.run() self.assertEqual(len(client.output_list), 2)
def __init__(self, allow_network_plugins=False, always_allow_plugins=None): with patch.object(JenniferGmailSharedSettings, 'get_accounts', test_get_gmail_accounts([])): JenniferBrain.__init__(self, allow_network_plugins, always_allow_plugins)
from lessons.base.responses import JenniferResponse, JenniferTextResponseSegment from lessons.JenniferGmailPlugin.plugin import JenniferGmailPlugin from lessons.JenniferGmailPlugin.logic import GmailImapWrapper from lessons.JenniferGmailPlugin.shared_settings import JenniferGmailSharedSettings @mock.patch.object(GmailImapWrapper, '_get_status', mock_imap_status) @mock.patch.object(GmailImapWrapper, 'login_and_select', mock_imap_do_nothing) @mock.patch.object(GmailImapWrapper, 'logout_and_close', mock_imap_do_nothing) @mock.patch.object(GmailImapWrapper, 'get_unread_emails', mock_imap_get_unread_emails) @mock.patch.object(GmailImapWrapper, 'get_first_text_block', mock_imap_get_first_text_block) @mock.patch.object(JenniferGmailSharedSettings, 'get_accounts', test_get_gmail_accounts()) class JenniferGmailPluginTests(unittest.TestCase): def setUp(self): self.brain = JenniferTestBrain( always_allow_plugins=[JenniferGmailPlugin]) self.brain.disable_unsure_response() def test_counting(self): inputs = ["count unread emails"] client = JenniferTestClient(self.brain, inputs) self.assertEqual(len(client.output_list), 2) response = client.output_list[0] self.assertEqual( "JenniferGmailPlugin",