def conversations_session(token): """ Create a Conversations API for testing, uses the token for auth """ channel = fake_channel(token) conversations_pb2_grpc.add_ConversationsServicer_to_server(Conversations(), channel) yield conversations_pb2_grpc.ConversationsStub(channel)
def conversations_session(db, token): """ Create a Conversations API for testing, uses the token for auth """ user_id, jailed = Auth(db).get_session_for_token(token) channel = FakeChannel(user_id=user_id) conversations_pb2_grpc.add_ConversationsServicer_to_server( Conversations(db), channel) yield conversations_pb2_grpc.ConversationsStub(channel)
servicer = API() server = grpc.server( futures.ThreadPoolExecutor(2), interceptors=[ ErrorSanitizationInterceptor(), LoggingInterceptor(), auth.get_auth_interceptor(allow_jailed=False), ], ) server.add_insecure_port("[::]:1751") account_pb2_grpc.add_AccountServicer_to_server(Account(), server) api_pb2_grpc.add_APIServicer_to_server(servicer, server) communities_pb2_grpc.add_CommunitiesServicer_to_server( Communities(), server) conversations_pb2_grpc.add_ConversationsServicer_to_server( Conversations(), server) discussions_pb2_grpc.add_DiscussionsServicer_to_server( Discussions(), server) gis_pb2_grpc.add_GISServicer_to_server(GIS(), server) groups_pb2_grpc.add_GroupsServicer_to_server(Groups(), server) pages_pb2_grpc.add_PagesServicer_to_server(Pages(), server) references_pb2_grpc.add_ReferencesServicer_to_server(References(), server) requests_pb2_grpc.add_RequestsServicer_to_server(Requests(), server) search_pb2_grpc.add_SearchServicer_to_server(Search(), server) threads_pb2_grpc.add_ThreadsServicer_to_server(Threads(), server) server.start() media_server = grpc.server( futures.ThreadPoolExecutor(2), interceptors=[