def test_unflag_message( self, client: StreamChat, channel, random_user, server_user: Dict ): msg_id = str(uuid.uuid4()) channel.send_message({"id": msg_id, "text": "helloworld"}, random_user["id"]) client.flag_message(msg_id, user_id=server_user["id"]) client.unflag_message(msg_id, user_id=server_user["id"])
def test_review_flag_report( self, client: StreamChat, channel, random_user, server_user: Dict ): msg = {"id": str(uuid.uuid4()), "text": "hello world"} channel.send_message(msg, random_user["id"]) client.flag_message(msg["id"], user_id=server_user["id"]) try: wait_for( lambda: client._query_flag_reports(message_id=msg["id"]), timeout=10 ) except Exception: # The backend is sometimes unstable ¯\_(ツ)_/¯ return response = client._query_flag_reports(message_id=msg["id"]) response = client._review_flag_report( report_id=response["flag_reports"][0]["id"], review_result="reviewed", user_id=random_user["id"], custom="reason_a", ) report = response["flag_report"] assert report["id"] is not None assert report["message"]["id"] == msg["id"] assert report["message"]["text"] == msg["text"] assert report["review_result"] == "reviewed" assert report["review_details"]["custom"] == "reason_a"
def test_query_message_flags( self, client: StreamChat, channel, random_user, server_user: Dict ): msg_id = str(uuid.uuid4()) channel.send_message({"id": msg_id, "text": "helloworld"}, random_user["id"]) client.flag_message(msg_id, user_id=server_user["id"]) response = client.query_message_flags({"channel_cid": channel.cid}) assert len(response["flags"]) == 1 response = client.query_message_flags({"user_id": {"$in": [random_user["id"]]}}) assert len(response["flags"]) == 1
def test_query_flag_reports( self, client: StreamChat, channel, random_user, server_user: Dict ): msg = {"id": str(uuid.uuid4()), "text": "hello world"} channel.send_message(msg, random_user["id"]) client.flag_message(msg["id"], user_id=server_user["id"]) try: wait_for( lambda: client._query_flag_reports(message_id=msg["id"]), timeout=10 ) except Exception: # The backend is sometimes unstable ¯\_(ツ)_/¯ return response = client._query_flag_reports(message_id=msg["id"]) assert len(response["flag_reports"]) == 1 report = response["flag_reports"][0] assert report["id"] is not None assert report["message"]["id"] == msg["id"] assert report["message"]["text"] == msg["text"]