Exemplo n.º 1
0
class TestCheckEmailPlugin(unittest.TestCase):
    def setUp(self):
        self.plugin = testutils.get_plugin_instance(
            check_email.CheckEmailPlugin)

    @unittest.skipIf(not diagnose.check_network_connection(),
                     "No internet connection")
    def test_handle_method(self):
        if not profile.get(['email', 'password']):
            self.skipTest("Email password not available")

        mic = testutils.TestMic()
        self.plugin.handle({'input': "Check my email account!"}, mic)
Exemplo n.º 2
0
class TestGmailPlugin(unittest.TestCase):
    def setUp(self):
        self.plugin = testutils.get_plugin_instance(
            news2.NewsPlugin
        )

    @unittest.skipIf(not diagnose.check_network_connection(),
                     "No internet connection")
    def test_handle_method(self):
        mic = testutils.TestMic(inputs=["No."])
        self.plugin.handle("Find me some of the top news stories.", mic)
        self.assertGreater(len(mic.outputs), 1)
        self.assertIn("top headlines", mic.outputs[1])
Exemplo n.º 3
0
class TestWeatherPlugin(unittest.TestCase):
    def setUp(self):
        self.plugin = testutils.get_plugin_instance(weather.WeatherPlugin)

    def test_is_valid_method(self):
        self.assertTrue(
            self.plugin.is_valid("What's the weather like tomorrow?"))
        self.assertFalse(self.plugin.is_valid("What time is it?"))

    @unittest.skipIf(not diagnose.check_network_connection(),
                     "No internet connection")
    def test_get_woeid_method(self):
        self.assertEqual(weather.get_woeid('New York'), 2459115)

    @unittest.skipIf(not diagnose.check_network_connection(),
                     "No internet connection")
    def test_handle_method(self):
        mic = testutils.TestMic()
        self.plugin.handle("What's the weather like tomorrow?", mic)
        self.assertEqual(len(mic.outputs), 1)

        self.assertTrue("can't see that far ahead" in mic.outputs[0]
                        or "Tomorrow" in mic.outputs[0])
Exemplo n.º 4
0
class TestGmailPlugin(unittest.TestCase):
    def setUp(self):
        self.plugin = testutils.get_plugin_instance(gmail.GmailPlugin)

    def test_is_valid_method(self):
        self.assertTrue(self.plugin.is_valid("Do I have new email?"))
        self.assertTrue(self.plugin.is_valid("Check my email account!"))
        self.assertFalse(self.plugin.is_valid("What time is it?"))

    @unittest.skipIf(not diagnose.check_network_connection(),
                     "No internet connection")
    def test_handle_method(self):
        key = 'gmail_password'
        if key not in self.plugin.profile or not self.plugin.profile[key]:
            self.skipTest("Gmail password not available")

        mic = testutils.TestMic()
        self.plugin.handle("Check my email account!", mic)
Exemplo n.º 5
0
class TestGmailPlugin(unittest.TestCase):
    def setUp(self):
        self.plugin = testutils.get_plugin_instance(
            hackernews.HackerNewsPlugin)

    def test_is_valid_method(self):
        self.assertTrue(
            self.plugin.is_valid(
                "Find me some of the top hacker news stories."))
        self.assertFalse(self.plugin.is_valid("What time is it?"))

    @unittest.skipIf(not diagnose.check_network_connection(),
                     "No internet connection")
    def test_handle_method(self):
        mic = testutils.TestMic(inputs=["No."])
        self.plugin.handle("Find me some of the top hacker news stories.", mic)
        self.assertGreater(len(mic.outputs), 1)
        self.assertIn("current top stories", mic.outputs[1])