mirror of
https://github.com/fastapi/fastapi.git
synced 2026-10-26 03:39:25 -04:00
✨ Add testing docs and tests (#151)
* ✏️ Fix typo in security intro * ✨ Add testing docs and tests * 🐛 Debug Travis coverage * 🐛 Debug Travis coverage, report XML * 💚 Make Travis/Flit use same code install * ⏪ Revert Travis/Codecov debugging changes
This commit is contained in:
1 parent
613e211d20
commit
46e3811f8d
17 files changed
+241
-5
No files matched your search
Whitespace-only changes.
@@ -0,0 +1,30 @@
|
||||
from app_testing.test_main import client, test_read_main
|
||||
|
||||
openapi_schema = {
|
||||
"openapi": "3.0.2",
|
||||
"info": {"title": "Fast API", "version": "0.1.0"},
|
||||
"paths": {
|
||||
"/": {
|
||||
"get": {
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "Successful Response",
|
||||
"content": {"application/json": {"schema": {}}},
|
||||
}
|
||||
},
|
||||
"summary": "Read Main Get",
|
||||
"operationId": "read_main__get",
|
||||
}
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
def test_openapi_schema():
|
||||
response = client.get("/openapi.json")
|
||||
assert response.status_code == 200
|
||||
assert response.json() == openapi_schema
|
||||
|
||||
|
||||
def test_main():
|
||||
test_read_main()
|
||||
@@ -0,0 +1,30 @@
|
||||
from app_testing.tutorial001 import client, test_read_main
|
||||
|
||||
openapi_schema = {
|
||||
"openapi": "3.0.2",
|
||||
"info": {"title": "Fast API", "version": "0.1.0"},
|
||||
"paths": {
|
||||
"/": {
|
||||
"get": {
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "Successful Response",
|
||||
"content": {"application/json": {"schema": {}}},
|
||||
}
|
||||
},
|
||||
"summary": "Read Main Get",
|
||||
"operationId": "read_main__get",
|
||||
}
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
def test_openapi_schema():
|
||||
response = client.get("/openapi.json")
|
||||
assert response.status_code == 200
|
||||
assert response.json() == openapi_schema
|
||||
|
||||
|
||||
def test_main():
|
||||
test_read_main()
|
||||
@@ -0,0 +1,9 @@
|
||||
from app_testing.tutorial002 import test_read_main, test_websocket
|
||||
|
||||
|
||||
def test_main():
|
||||
test_read_main()
|
||||
|
||||
|
||||
def test_ws():
|
||||
test_websocket()
|
||||
@@ -0,0 +1,5 @@
|
||||
from app_testing.tutorial003 import test_read_items
|
||||
|
||||
|
||||
def test_main():
|
||||
test_read_items()
|
||||
Reference in new issue
Block a user