Coverage for tests/test_playground.py: 100%

17 statements  

« prev     ^ index     » next       coverage.py v7.15.3, created at 2026-08-03 00:00 +0000

1import typing 

2 

3import pytest 

4from fastapi.testclient import TestClient 

5 

6from tests.playground import INDEX_PATH, PLAYGROUND_EXAMPLES, playground_app, render_example_path 

7from tests.served_page import GOOD_HTTP_CODE 

8 

9 

10def test_index_links_every_example() -> None: 

11 response: typing.Final = TestClient(playground_app).get(INDEX_PATH) 

12 

13 assert response.status_code == GOOD_HTTP_CODE 

14 for one_example_name, one_example_settings in PLAYGROUND_EXAMPLES.items(): 

15 assert f'href="/{one_example_name}/"' in response.text 

16 assert one_example_settings.service_name in response.text 

17 

18 

19@pytest.mark.parametrize("example_name", PLAYGROUND_EXAMPLES) 

20def test_example_page_serves_its_own_service(example_name: str) -> None: 

21 response: typing.Final = TestClient(playground_app).get(render_example_path(example_name)) 

22 

23 assert response.status_code == GOOD_HTTP_CODE 

24 assert "graph TB" in response.text 

25 assert PLAYGROUND_EXAMPLES[example_name].service_name in response.text