예제 #1
0
    def test_process_incoming_membership_check_sender_pass(self, m):
        m.get('https://api.ciscospark.com/v1/webhooks',
              json=MockSparkAPI.list_webhooks())
        m.post('https://api.ciscospark.com/v1/webhooks',
               json=MockSparkAPI.create_webhook())
        m.post('//api.ciscospark.com/v1/messages', json={})
        bot_email = "*****@*****.**"
        spark_token = "somefaketoken"
        bot_url = "http://fakebot.com"
        bot_app_name = "testbot"
        # Create a new bot
        bot = SparkBot(bot_app_name,
                       spark_bot_token=spark_token,
                       spark_bot_url=bot_url,
                       spark_bot_email=bot_email,
                       debug=True,
                       wh_resource="memberships",
                       wh_event="all")

        # Add new command
        bot.add_command('memberships',
                        '*',
                        self.check_membership)
        bot.testing = True
        self.app = bot.test_client()

        resp = self.app.post('/',
                             data=MockSparkAPI.incoming_membership_pass(),
                             content_type="application/json")
        self.assertEqual(resp.status_code, 200)
        print(resp.data)
        self.assertIn(b"success", resp.data)
예제 #2
0
    def setUp(self, m):
        m.get('https://api.ciscospark.com/v1/webhooks',
              json=MockSparkAPI.list_webhooks())
        m.post('https://api.ciscospark.com/v1/webhooks',
               json=MockSparkAPI.create_webhook())
        bot_email = "*****@*****.**"
        spark_token = "somefaketoken"
        bot_url = "http://fakebot.com"
        bot_app_name = "testbot"
        # Create a new bot
        bot = SparkBot(bot_app_name,
                       spark_bot_token=spark_token,
                       spark_bot_url=bot_url,
                       spark_bot_email=bot_email,
                       debug=True)

        # Add new command
        bot.add_command('/dosomething',
                        'help for do something',
                        self.do_something)
        bot.testing = True
        self.app = bot.test_client()
예제 #3
0
    def test_bad_config_raises_valueerror(self, m):
        with self.assertRaises(ValueError):
            m.get('https://api.ciscospark.com/v1/webhooks',
                  json=MockSparkAPI.list_webhooks_exist())
            m.post('https://api.ciscospark.com/v1/webhooks',
                   json=MockSparkAPI.create_webhook())

            bot_email = None
            spark_token = "somefaketoken"
            bot_url = "http://fakebot.com"
            bot_app_name = "testbot"
            # Create a new bot
            bot = SparkBot(bot_app_name,
                           spark_bot_token=spark_token,
                           spark_bot_url=bot_url,
                           spark_bot_email=bot_email,
                           debug=True)

            # Add new command
            bot.add_command('/dosomething',
                            'help for do something',
                            self.do_something)
            bot.testing = True
            self.app = bot.test_client()