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)
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()
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()