From ec09ae6bd574c8082f9870b5f16018d4eeed364b Mon Sep 17 00:00:00 2001 From: ftsell Date: Mon, 12 Feb 2024 21:37:47 +0100 Subject: [PATCH] make generated metric exposition test more exhaustive --- .../metrics/tests/test_metric_exposition.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) 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