File: test_ninja_views.py

package info (click to toggle)
python-django-structlog 9.1.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,004 kB
  • sloc: python: 3,509; sh: 206; javascript: 79; makefile: 19
file content (17 lines) | stat: -rw-r--r-- 505 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
import pytest
from ninja.testing import TestClient

from ..ninja_views import router

pytestmark = pytest.mark.django_db


class TestNinjaView:
    def test(self, caplog, request_factory):
        client = TestClient(router)
        response = client.get("/ninja")
        assert response.status_code == 200
        assert response.json() == {"result": "ok"}
        assert len(caplog.records) == 1
        record = caplog.records[0]
        assert record.msg["event"] == "This is a ninja structured log"