mirror of https://github.com/tiangolo/fastapi.git
✅ Increase tests for coverage
This commit is contained in:
parent
be1bca1c1f
commit
723a76f481
|
|
@ -69,6 +69,22 @@ def test_root():
|
|||
assert response.json() == {"message": "Hello World"}
|
||||
|
||||
|
||||
def test_read_with_oauth2_scheme():
|
||||
response = client.get(
|
||||
"/with-oauth2-scheme", headers={"Authorization": "Bearer testtoken"}
|
||||
)
|
||||
assert response.status_code == 200, response.text
|
||||
assert response.json() == {"message": "Admin Access"}
|
||||
|
||||
|
||||
def test_read_with_get_token():
|
||||
response = client.get(
|
||||
"/with-get-token", headers={"Authorization": "Bearer testtoken"}
|
||||
)
|
||||
assert response.status_code == 200, response.text
|
||||
assert response.json() == {"message": "Admin Access"}
|
||||
|
||||
|
||||
def test_read_token():
|
||||
response = client.get("/items/", headers={"Authorization": "Bearer testtoken"})
|
||||
assert response.status_code == 200, response.text
|
||||
|
|
|
|||
|
|
@ -28,6 +28,12 @@ async def read_admin():
|
|||
client = TestClient(app)
|
||||
|
||||
|
||||
def test_read_admin():
|
||||
response = client.get("/admin", headers={"Authorization": "Bearer faketoken"})
|
||||
assert response.status_code == 200, response.text
|
||||
assert response.json() == {"message": "Admin Access"}
|
||||
|
||||
|
||||
def test_openapi_schema():
|
||||
response = client.get("/openapi.json")
|
||||
assert response.status_code == 200, response.text
|
||||
|
|
|
|||
Loading…
Reference in New Issue