diff --git a/{{ cookiecutter.project_slug }}/src/{{ cookiecutter.project_slug }}/metrics/tests/test_metric_exposition.py b/{{ cookiecutter.project_slug }}/src/{{ cookiecutter.project_slug }}/metrics/tests/test_metric_exposition.py index f18f8d7..06238f1 100644 --- a/{{ cookiecutter.project_slug }}/src/{{ cookiecutter.project_slug }}/metrics/tests/test_metric_exposition.py +++ b/{{ cookiecutter.project_slug }}/src/{{ cookiecutter.project_slug }}/metrics/tests/test_metric_exposition.py @@ -1,7 +1,12 @@ +import pytest from django.shortcuts import resolve_url from django.test import Client +from prometheus_client.parser import text_string_to_metric_families -def test_metric_endpoint_returns_200(client: Client): +@pytest.mark.django_db +def test_metric_endpoint_returns_valid_prometheus_data(client: Client): response = client.get(resolve_url("prometheus_metrics")) assert response.status_code == 200 + metrics = list(text_string_to_metric_families(response.content.decode("UTF-8"))) + assert len(metrics) > 0