@@ -1016,3 +1016,58 @@ def test_query_message_history(
10161016
10171017 assert len (response_next ["message_history" ]) == 1
10181018 assert response_next ["message_history" ][0 ]["text" ] == "helloworld-2"
1019+
1020+ def test_mark_delivered (self , client : StreamChat , channel : Channel , random_user : Dict ):
1021+ """Test marking messages as delivered"""
1022+ # Test with basic delivery data using new format
1023+ delivery_data = {
1024+ "latest_delivered_messages" : [
1025+ {
1026+ "cid" : channel .cid ,
1027+ "id" : "test-message-id"
1028+ }
1029+ ],
1030+ "user_id" : random_user ["id" ]
1031+ }
1032+
1033+ response = client .mark_delivered (delivery_data )
1034+ assert response is not None
1035+
1036+ # Test with multiple messages
1037+ delivery_data_multiple = {
1038+ "latest_delivered_messages" : [
1039+ {
1040+ "cid" : channel .cid ,
1041+ "id" : "test-message-id-1"
1042+ },
1043+ {
1044+ "cid" : channel .cid ,
1045+ "id" : "test-message-id-2"
1046+ }
1047+ ],
1048+ "user_id" : random_user ["id" ]
1049+ }
1050+
1051+ response = client .mark_delivered (delivery_data_multiple )
1052+ assert response is not None
1053+
1054+ def test_mark_delivered_simple (self , client : StreamChat , channel : Channel , random_user : Dict ):
1055+ """Test the convenience method for marking messages as delivered"""
1056+ response = client .mark_delivered_simple (
1057+ user_id = random_user ["id" ],
1058+ message_id = "test-message-id" ,
1059+ channel_cid = channel .cid
1060+ )
1061+ assert response is not None
1062+
1063+ def test_mark_delivered_validation (self , client : StreamChat , random_user : Dict ):
1064+ """Test validation of mark_delivered method"""
1065+ # Test empty latest_delivered_messages
1066+ with pytest .raises (ValueError , match = "latest_delivered_messages must not be empty" ):
1067+ client .mark_delivered ({"user_id" : random_user ["id" ]})
1068+
1069+ # Test missing user and user_id
1070+ with pytest .raises (ValueError , match = "either user or user_id must be provided" ):
1071+ client .mark_delivered ({
1072+ "latest_delivered_messages" : [{"cid" : "test:channel" , "id" : "test" }]
1073+ })
0 commit comments