Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
test_management_commands: Fix check that bots aren’t notified.
Anders Kaseorg4dacd6db094d
diff --git a/zerver/tests/test_management_commands.py b/zerver/tests/test_management_commands.pyindex 52664098ad0..c9959b95ec0 100644--- a/zerver/tests/test_management_commands.py+++ b/zerver/tests/test_management_commands.py@@ -23,7 +23,7 @@ from zerver.actions.user_settings import do_change_user_settingfrom zerver.lib.management import ZulipBaseCommand, skip_unless_lockedfrom zerver.lib.test_classes import ZulipTestCasefrom zerver.lib.test_helpers import most_recent_message, stdout_suppressed-from zerver.models import Realm, RealmAuditLog, Recipient, UserProfile+from zerver.models import Realm, RealmAuditLog, Recipient, UserMessage, UserProfilefrom zerver.models.realm_audit_logs import AuditLogEventTypefrom zerver.models.realms import get_realmfrom zerver.models.streams import get_stream@@ -849,11 +849,7 @@ class TestUserChangeNotifications(ZulipTestCase):realm = hamlet.realm# Count bot messages before changes- from zerver.models import Message-- bot_messages_before = Message.objects.filter(- realm_id=realm.id, recipient__type_id=bot.id- ).count()+ bot_messages_before = UserMessage.objects.filter(user_profile=bot).count()import tempfile@@ -885,9 +881,7 @@ class TestUserChangeNotifications(ZulipTestCase):self.assertEqual(bot.full_name, "New Bot Name")# Verify bot did NOT receive a notification- bot_messages_after = Message.objects.filter(- realm_id=realm.id, recipient__type_id=bot.id- ).count()+ bot_messages_after = UserMessage.objects.filter(user_profile=bot).count()self.assertEqual(bot_messages_before, bot_messages_after)finally:os.unlink(data_file)@@ -919,11 +913,7 @@ class TestUserChangeNotifications(ZulipTestCase):bot = self.example_user("default_bot")# Count bot messages before changes- from zerver.models import Message-- bot_messages_before = Message.objects.filter(- realm_id=realm.id, recipient__type_id=bot.id- ).count()+ bot_messages_before = UserMessage.objects.filter(user_profile=bot).count()with stdout_suppressed():call_command(@@ -935,7 +925,5 @@ class TestUserChangeNotifications(ZulipTestCase):self.assertEqual(bot.role, UserProfile.ROLE_MODERATOR)# Verify bot did NOT receive a notification- bot_messages_after = Message.objects.filter(- realm_id=realm.id, recipient__type_id=bot.id- ).count()+ bot_messages_after = UserMessage.objects.filter(user_profile=bot).count()self.assertEqual(bot_messages_before, bot_messages_after)