Coverage for app / backend / src / tests / test_gis.py: 100%

33 statements  

« prev     ^ index     » next       coverage.py v7.13.2, created at 2026-02-03 06:18 +0000

1import json 

2 

3import pytest 

4from google.protobuf import empty_pb2 

5 

6from couchers.materialized_views import refresh_materialized_views, refresh_materialized_views_rapid 

7from tests.fixtures.db import generate_user 

8from tests.fixtures.sessions import gis_session 

9from tests.test_communities import testing_communities # noqa 

10 

11 

12@pytest.fixture(autouse=True) 

13def _(testconfig): 

14 pass 

15 

16 

17class TestGIS: 

18 @staticmethod 

19 def test_GetUsers(testing_communities): 

20 _, token = generate_user() 

21 

22 refresh_materialized_views_rapid(empty_pb2.Empty()) 

23 

24 with gis_session(token) as gis: 

25 http_body = gis.GetUsers(empty_pb2.Empty()) 

26 assert http_body.content_type == "application/json" 

27 data = json.loads(http_body.data) 

28 print(data) 

29 assert data["type"] == "FeatureCollection" 

30 assert len(data["features"]) > 1 

31 

32 @staticmethod 

33 def test_GetClusteredUsers(testing_communities): 

34 _, token = generate_user() 

35 

36 refresh_materialized_views(empty_pb2.Empty()) 

37 

38 with gis_session(token) as gis: 

39 http_body = gis.GetClusteredUsers(empty_pb2.Empty()) 

40 assert http_body.content_type == "application/json" 

41 data = json.loads(http_body.data) 

42 print(data) 

43 assert data["type"] == "FeatureCollection" 

44 assert len(data["features"]) > 1