Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
test_bots: Use the default bot metadata for incoming webhook bot tests.
Niloth P464dc1244d0e
diff --git a/zerver/tests/test_bots.py b/zerver/tests/test_bots.pyindex 5b9a65b0b3e..7571e8b5e3c 100644--- a/zerver/tests/test_bots.py+++ b/zerver/tests/test_bots.py@@ -2220,16 +2220,12 @@ class BotTest(ZulipTestCase, UploadSerializeMixin):@patch("zerver.lib.integrations.INCOMING_WEBHOOK_INTEGRATIONS", test_sample_config_options)def test_create_incoming_webhook_bot_with_service_name_and_with_keys(self) -> None:self.login("hamlet")- bot_metadata = {- "full_name": "My Stripe Bot",- "short_name": "my-stripe",- "bot_type": UserProfile.INCOMING_WEBHOOK_BOT,- "service_name": "stripe",- "config_data": orjson.dumps({"stripe_api_key": "sample-api-key"}).decode(),- }- self.create_bot(**bot_metadata)- new_bot = UserProfile.objects.get(full_name="My Stripe Bot")- config_data = get_bot_config(new_bot)+ result = self.create_bot(+ bot_type=UserProfile.INCOMING_WEBHOOK_BOT,+ service_name="stripe",+ config_data=orjson.dumps({"stripe_api_key": "sample-api-key"}).decode(),+ )+ config_data = get_bot_config(UserProfile.objects.get(id=result["user_id"]))self.assertEqual(config_data, {"integration_id": "stripe", "stripe_api_key": "sample-api-key"})@@ -2237,27 +2233,16 @@ class BotTest(ZulipTestCase, UploadSerializeMixin):@patch("zerver.lib.integrations.INCOMING_WEBHOOK_INTEGRATIONS", test_sample_config_options)def test_create_incoming_webhook_bot_with_service_name_and_no_config_options(self) -> None:self.login("hamlet")- bot_metadata = {- "full_name": "My Hello World Bot",- "short_name": "my-helloworld",- "bot_type": UserProfile.INCOMING_WEBHOOK_BOT,- "service_name": "helloworld",- }- self.create_bot(**bot_metadata)- new_bot = UserProfile.objects.get(full_name="My Hello World Bot")- config_data = get_bot_config(new_bot)+ result = self.create_bot(+ bot_type=UserProfile.INCOMING_WEBHOOK_BOT, service_name="helloworld"+ )+ config_data = get_bot_config(UserProfile.objects.get(id=result["user_id"]))self.assertEqual(config_data, {"integration_id": "helloworld"})- @patch("zerver.lib.integrations.INCOMING_WEBHOOK_INTEGRATIONS", test_sample_config_options)def test_create_incoming_webhook_bot_without_service_name(self) -> None:self.login("hamlet")- bot_metadata = {- "full_name": "My Stripe Bot",- "short_name": "my-stripe",- "bot_type": UserProfile.INCOMING_WEBHOOK_BOT,- }- self.create_bot(**bot_metadata)- new_bot = UserProfile.objects.get(full_name="My Stripe Bot")+ result = self.create_bot(bot_type=UserProfile.INCOMING_WEBHOOK_BOT)+ new_bot = UserProfile.objects.get(id=result["user_id"])with self.assertRaises(ConfigError):get_bot_config(new_bot)