11from datetime import timedelta
22
3+ import grpc
34import pytest
45
56from couchers .db import session_scope
@@ -146,7 +147,7 @@ def test_list_message_threads_single_cursor_pagination_across_kinds(db, moderato
146147 with conversations_session (token1 ) as c :
147148 res = c .ListMessageThreads (
148149 conversations_pb2 .ListMessageThreadsReq (
149- filter = conversations_pb2 .MESSAGE_THREAD_FILTER_ALL , number = 3 , page_token = page_token
150+ filter = conversations_pb2 .MESSAGE_THREAD_FILTER_ALL , page_size = 3 , page_token = page_token
150151 )
151152 )
152153 for t in res .threads :
@@ -183,6 +184,23 @@ def test_list_message_threads_chats_filter_excludes_host_requests(db, moderator)
183184 assert res .threads [0 ].group_chat .group_chat_id == chat_id
184185
185186
187+ def test_message_threads_reject_unspecified_filter (db ):
188+ user1 , token1 = generate_user ()
189+
190+ with conversations_session (token1 ) as c :
191+ with pytest .raises (grpc .RpcError ) as e :
192+ c .ListMessageThreads (
193+ conversations_pb2 .ListMessageThreadsReq (filter = conversations_pb2 .MESSAGE_THREAD_FILTER_UNSPECIFIED )
194+ )
195+ assert e .value .code () == grpc .StatusCode .INVALID_ARGUMENT
196+
197+ with pytest .raises (grpc .RpcError ) as e :
198+ c .MarkAllThreadsSeen (
199+ conversations_pb2 .MarkAllThreadsSeenReq (filter = conversations_pb2 .MESSAGE_THREAD_FILTER_UNSPECIFIED )
200+ )
201+ assert e .value .code () == grpc .StatusCode .INVALID_ARGUMENT
202+
203+
186204def test_list_message_threads_unread_filter (db , moderator ):
187205 user1 , token1 = generate_user ()
188206 user2 , token2 = generate_user ()
@@ -251,11 +269,11 @@ def test_list_message_threads_public_trip_offer_role_based(db, moderator):
251269 assert len (res .threads ) == 1
252270 hr = res .threads [0 ].host_request
253271 assert hr .host_request_id == request_id
254- assert hr .is_public_trip_offer
272+ assert hr .HasField ( "public_trip_id" )
255273 assert hr .public_trip_id == trip_id
274+ # viewer is the offering host: host_user_id == own id (viewer_is_host derived client-side)
256275 assert hr .host_user_id == host .id
257276 assert hr .surfer_user_id == traveler .id
258- assert hr .viewer_is_host
259277
260278 # not under SURFING for the host
261279 res = c .ListMessageThreads (
@@ -270,8 +288,9 @@ def test_list_message_threads_public_trip_offer_role_based(db, moderator):
270288 )
271289 assert [t .host_request .host_request_id for t in res .threads ] == [request_id ]
272290 assert res .threads [0 ].host_request .surfer_user_id == traveler .id
291+ # viewer is the traveller, not the host: host_user_id != own id
273292 assert res .threads [0 ].host_request .host_user_id == host .id
274- assert not res .threads [0 ].host_request .viewer_is_host
293+ assert res .threads [0 ].host_request .host_user_id != traveler . id
275294
276295 res = c .ListMessageThreads (
277296 conversations_pb2 .ListMessageThreadsReq (filter = conversations_pb2 .MESSAGE_THREAD_FILTER_PUBLIC_TRIPS )
0 commit comments