Browse Source

Add tests for metadata

pull/11/head
Sebastián Ramírez 6 years ago
parent
commit
6b9931f882
  1. 0
      docs/src/application_configuration/tutorial001.py
  2. 0
      docs/src/application_configuration/tutorial002.py
  3. 0
      docs/src/application_configuration/tutorial003.py
  4. 6
      docs/tutorial/application-configuration.md
  5. 0
      tests/test_tutorial/test_application_configuration/__init__.py
  6. 34
      tests/test_tutorial/test_application_configuration/test_tutorial001.py
  7. 0
      tests/test_tutorial/test_query_params_str_validations/__init__.py
  8. 86
      tests/test_tutorial/test_query_params_str_validations/test_tutorial001.py

0
docs/src/application-configuration/tutorial001.py → docs/src/application_configuration/tutorial001.py

0
docs/src/application-configuration/tutorial002.py → docs/src/application_configuration/tutorial002.py

0
docs/src/application-configuration/tutorial003.py → docs/src/application_configuration/tutorial003.py

6
docs/tutorial/application-configuration.md

@ -1,13 +1,13 @@
Coming soon...
```Python
{!./src/application-configuration/tutorial001.py!}
{!./src/application_configuration/tutorial001.py!}
```
```Python
{!./src/application-configuration/tutorial002.py!}
{!./src/application_configuration/tutorial002.py!}
```
```Python
{!./src/application-configuration/tutorial003.py!}
{!./src/application_configuration/tutorial003.py!}
```

0
tests/test_tutorial/test_application_configuration/__init__.py

34
tests/test_tutorial/test_application_configuration/test_tutorial001.py

@ -0,0 +1,34 @@
from starlette.testclient import TestClient
from application_configuration.tutorial001 import app
client = TestClient(app)
openapi_schema = {
"openapi": "3.0.2",
"info": {
"title": "My Super Project",
"version": "2.5.0",
"description": "This is a very fancy project, with auto docs for the API and everything",
},
"paths": {
"/items/": {
"get": {
"responses": {
"200": {
"description": "Successful Response",
"content": {"application/json": {"schema": {}}},
}
},
"summary": "Read Items Get",
"operationId": "read_items_items__get",
}
}
},
}
def test_openapi_scheme():
response = client.get("/openapi.json")
assert response.status_code == 200
assert response.json() == openapi_schema

0
tests/test_tutorial/test_query_params_str_validations/__init__.py

86
tests/test_tutorial/test_query_params_str_validations/test_tutorial001.py

@ -0,0 +1,86 @@
from starlette.testclient import TestClient
from query_params_str_validations.tutorial010 import app
client = TestClient(app)
openapi_schema = {
"openapi": "3.0.2",
"info": {"title": "Fast API", "version": "0.1.0"},
"paths": {
"/items/": {
"get": {
"responses": {
"200": {
"description": "Successful Response",
"content": {"application/json": {"schema": {}}},
},
"422": {
"description": "Validation Error",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/HTTPValidationError"
}
}
},
},
},
"summary": "Read Items Get",
"operationId": "read_items_items__get",
"parameters": [
{
"description": "Query string for the items to search in the database that have a good match",
"required": False,
"deprecated": True,
"schema": {
"title": "Query string",
"maxLength": 50,
"minLength": 3,
"pattern": "^fixedquery$",
"type": "string",
"description": "Query string for the items to search in the database that have a good match",
},
"name": "item-query",
"in": "query",
}
],
}
}
},
"components": {
"schemas": {
"ValidationError": {
"title": "ValidationError",
"required": ["loc", "msg", "type"],
"type": "object",
"properties": {
"loc": {
"title": "Location",
"type": "array",
"items": {"type": "string"},
},
"msg": {"title": "Message", "type": "string"},
"type": {"title": "Error Type", "type": "string"},
},
},
"HTTPValidationError": {
"title": "HTTPValidationError",
"type": "object",
"properties": {
"detail": {
"title": "Detail",
"type": "array",
"items": {"$ref": "#/components/schemas/ValidationError"},
}
},
},
}
},
}
def test_openapi_scheme():
response = client.get("/openapi.json")
assert response.status_code == 200
assert response.json() == openapi_schema
Loading…
Cancel
Save