mirror of
https://github.com/fastapi/fastapi.git
synced 2026-05-24 16:29:41 -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:
committed by
GitHub
parent
613e211d20
commit
46e3811f8d
@@ -24,8 +24,8 @@ openapi_schema = {
|
||||
},
|
||||
},
|
||||
},
|
||||
"summary": "Read Item Get",
|
||||
"operationId": "read_item_items__item_id__get",
|
||||
"summary": "Read Items Get",
|
||||
"operationId": "read_items_items__item_id__get",
|
||||
"parameters": [
|
||||
{
|
||||
"required": True,
|
||||
|
||||
0
tests/test_tutorial/test_testing/__init__.py
Normal file
0
tests/test_tutorial/test_testing/__init__.py
Normal file
30
tests/test_tutorial/test_testing/test_main.py
Normal file
30
tests/test_tutorial/test_testing/test_main.py
Normal file
@@ -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()
|
||||
30
tests/test_tutorial/test_testing/test_tutorial001.py
Normal file
30
tests/test_tutorial/test_testing/test_tutorial001.py
Normal file
@@ -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()
|
||||
9
tests/test_tutorial/test_testing/test_tutorial002.py
Normal file
9
tests/test_tutorial/test_testing/test_tutorial002.py
Normal file
@@ -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()
|
||||
5
tests/test_tutorial/test_testing/test_tutorial003.py
Normal file
5
tests/test_tutorial/test_testing/test_tutorial003.py
Normal file
@@ -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