Coverage for app/backend/src/tests/fixtures/api/gis.py: 100%

21 statements  

« prev     ^ index     » next       coverage.py v7.18.0, created at 2026-12-02 09:23 +0000

1from contextlib import contextmanager 

2from typing import cast 

3 

4import grpc 

5from google.protobuf import empty_pb2 

6 

7from couchers.proto import gis_pb2_grpc 

8from couchers.proto.google.api import httpbody_pb2 

9from couchers.servicers.gis import GIS 

10from tests.fixtures.sessions import FakeChannel 

11 

12 

13@contextmanager 

14def _gis_session(token: str): 

15 channel = FakeChannel(token) 

16 gis_pb2_grpc.add_GISServicer_to_server(GIS(), cast(grpc.Server, channel)) 

17 yield gis_pb2_grpc.GISStub(cast(grpc.Channel, channel)) 

18 

19 

20def get_users(*, token: str) -> httpbody_pb2.HttpBody: 

21 with _gis_session(token) as session: 

22 res: httpbody_pb2.HttpBody = session.GetUsers(empty_pb2.Empty()) 

23 return res 

24 

25 

26def get_clustered_users(*, token: str) -> httpbody_pb2.HttpBody: 

27 with _gis_session(token) as session: 

28 res: httpbody_pb2.HttpBody = session.GetClusteredUsers(empty_pb2.Empty()) 

29 return res