Serverless Apps with FastAPI
Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

tests.py 491B

12345678910111213141516171819202122
  1. import pytest
  2. from fastapi import status
  3. from starlette.testclient import TestClient
  4. from main import app
  5. @pytest.fixture
  6. def client():
  7. return TestClient(app)
  8. def test_health_check(client):
  9. """
  10. GIVEN
  11. WHEN health check endpoint is called with GET method
  12. THEN response with status 200 and body OK is returned
  13. """
  14. response = client.get("/api/health-check/")
  15. assert response.status_code == status.HTTP_200_OK
  16. assert response.json() == {"message": "OK"}