Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
events: Add assertions that all ops are implemented.
Tim Abbottdaa9bbba613b
diff --git a/zerver/lib/events.py b/zerver/lib/events.pyindex c69f1fa9aff..e1e3d1f759d 100644--- a/zerver/lib/events.py+++ b/zerver/lib/events.py@@ -625,23 +625,21 @@ def apply_event(p["profile_data"][str(custom_field_id)] = {"value": custom_field_new_value,}-+ else:+ raise AssertionError("Unexpected event type {type}/{op}".format(**event))elif event["type"] == "realm_bot":if event["op"] == "add":state["realm_bots"].append(event["bot"])-- if event["op"] == "remove":+ elif event["op"] == "remove":user_id = event["bot"]["user_id"]for bot in state["realm_bots"]:if bot["user_id"] == user_id:bot["is_active"] = False-- if event["op"] == "delete":+ elif event["op"] == "delete":state["realm_bots"] = [item for item in state["realm_bots"] if item["user_id"] != event["bot"]["user_id"]]-- if event["op"] == "update":+ elif event["op"] == "update":for bot in state["realm_bots"]:if bot["user_id"] == event["bot"]["user_id"]:if "owner_id" in event["bot"]:@@ -649,7 +647,8 @@ def apply_event(bot["owner_id"] = bot_owner_idelse:bot.update(event["bot"])-+ else:+ raise AssertionError("Unexpected event type {type}/{op}".format(**event))elif event["type"] == "stream":if event["op"] == "create":for stream in event["streams"]:@@ -743,6 +742,8 @@ def apply_event(if key == "authentication_methods":state["realm_password_auth_enabled"] = value["Email"] or value["LDAP"]state["realm_email_auth_enabled"] = value["Email"]+ else:+ raise AssertionError("Unexpected event type {type}/{op}".format(**event))elif event["type"] == "subscription":if event["op"] == "add":added_stream_ids = {sub["stream_id"] for sub in event["subscriptions"]}@@ -813,6 +814,8 @@ def apply_event(if sub["stream_id"] in stream_ids:subscribers = set(sub["subscribers"]) - user_idssub["subscribers"] = sorted(list(subscribers))+ else:+ raise AssertionError("Unexpected event type {type}/{op}".format(**event))elif event["type"] == "presence":if slim_presence:user_key = str(event["user_id"])@@ -923,6 +926,8 @@ def apply_event(for realm_domain in state["realm_domains"]if realm_domain["domain"] != event["domain"]]+ else:+ raise AssertionError("Unexpected event type {type}/{op}".format(**event))elif event["type"] == "realm_emoji":state["realm_emoji"] = event["realm_emoji"]elif event["type"] == "realm_export":@@ -966,6 +971,8 @@ def apply_event(state["realm_user_groups"] = [ug for ug in state["realm_user_groups"] if ug["id"] != event["group_id"]]+ else:+ raise AssertionError("Unexpected event type {type}/{op}".format(**event))elif event["type"] == "user_status":user_id_str = str(event["user_id"])user_status = state["user_status"]