2 changed files with 16 additions and 27 deletions
@ -1,27 +0,0 @@ |
|||||
from __future__ import annotations |
|
||||
|
|
||||
import http |
|
||||
import logging |
|
||||
|
|
||||
from fastapi import APIRouter, FastAPI |
|
||||
from fastapi.testclient import TestClient |
|
||||
|
|
||||
router = APIRouter() |
|
||||
|
|
||||
app = FastAPI() |
|
||||
|
|
||||
|
|
||||
@router.get("/no-content", status_code=http.HTTPStatus.NO_CONTENT) |
|
||||
def return_no_content() -> None: |
|
||||
logging.info("endpoint called") |
|
||||
|
|
||||
|
|
||||
app.include_router(router) |
|
||||
|
|
||||
client = TestClient(app) |
|
||||
|
|
||||
|
|
||||
def test_no_content(): |
|
||||
response = client.get("/no-content") |
|
||||
assert response.status_code == http.HTTPStatus.NO_CONTENT, response.text |
|
||||
assert not response.content |
|
||||
@ -0,0 +1,16 @@ |
|||||
|
import http |
||||
|
|
||||
|
from fastapi import FastAPI |
||||
|
from fastapi.testclient import TestClient |
||||
|
|
||||
|
|
||||
|
def test_no_content(): |
||||
|
app = FastAPI() |
||||
|
|
||||
|
@app.get("/no-content", status_code=http.HTTPStatus.NO_CONTENT) |
||||
|
def return_no_content() -> "None": ... # pragma: no cover |
||||
|
|
||||
|
client = TestClient(app) |
||||
|
response = client.get("/no-content") |
||||
|
assert response.status_code == http.HTTPStatus.NO_CONTENT, response.text |
||||
|
assert not response.content |
||||
Loading…
Reference in new issue