Coverage for src/tests/test_resources.py: 100%

32 statements  

« prev     ^ index     » next       coverage.py v7.5.0, created at 2024-12-20 18:03 +0000

1import pytest 

2from google.protobuf import empty_pb2 

3 

4from tests.test_fixtures import db, resources_session, testconfig # noqa 

5 

6 

7@pytest.fixture(autouse=True) 

8def _(testconfig): 

9 pass 

10 

11 

12def test_GetTermsOfService(): 

13 # make sure it works and we get out a bunch of text 

14 with resources_session() as api: 

15 res = api.GetTermsOfService(empty_pb2.Empty()).terms_of_service 

16 assert len(res) > 100 

17 assert "couchers, inc." in res.lower() 

18 

19 

20def test_GetCommunityGuidelines(): 

21 # make sure it works and we get out a bunch of text 

22 with resources_session() as api: 

23 res = api.GetCommunityGuidelines(empty_pb2.Empty()).community_guidelines 

24 assert len(res) == 4 

25 assert res[2].title == "Be safe and sensible" 

26 assert "inappropriate content" in res[2].guideline 

27 assert "stroke" in res[2].icon_svg 

28 

29 

30def test_GetRegions(db): 

31 with resources_session() as api: 

32 regions = api.GetRegions(empty_pb2.Empty()).regions 

33 regions_list = [(r.alpha3, r.name) for r in regions] 

34 assert ("FIN", "Finland") in regions_list 

35 assert ("SWE", "Sweden") in regions_list 

36 assert ("???", "Nonexistent region") not in regions_list 

37 

38 

39def test_GetLanguages(db): 

40 with resources_session() as api: 

41 languages = api.GetLanguages(empty_pb2.Empty()).languages 

42 languages_list = [(r.code, r.name) for r in languages] 

43 assert ("fin", "Finnish") in languages_list 

44 assert ("swe", "Swedish") in languages_list 

45 assert ("???", "Nonexistent language") not in languages_list