-
-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
75 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
from typing import Dict | ||
|
||
from esmerald import Esmerald, Gateway, get | ||
from esmerald.testclient import EsmeraldTestClient | ||
from tests.settings import TestSettings | ||
|
||
|
||
@get("/bar") | ||
async def bar() -> Dict[str, str]: | ||
return {"hello": "world"} | ||
|
||
|
||
app = Esmerald( | ||
contact={ | ||
"name": "API Support", | ||
"url": "https://www.example.com", | ||
"email": "[email protected]", | ||
}, | ||
routes=[Gateway(handler=bar)], | ||
enable_openapi=True, | ||
settings_config=TestSettings, | ||
) | ||
|
||
|
||
client = EsmeraldTestClient(app) | ||
|
||
|
||
def test_application(test_client_factory): | ||
response = client.get("/bar") | ||
assert response.status_code == 200, response.json() | ||
|
||
|
||
def test_openapi_schema(test_client_factory): | ||
response = client.get("/openapi.json") | ||
|
||
assert response.status_code == 200, response.text | ||
assert response.json() == { | ||
"openapi": "3.1.0", | ||
"info": { | ||
"title": "Esmerald", | ||
"summary": "Esmerald application", | ||
"description": "Highly scalable, performant, easy to learn and for every application.", | ||
"contact": { | ||
"name": "API Support", | ||
"url": "https://www.example.com/", | ||
"email": "[email protected]", | ||
}, | ||
"version": client.app.version, | ||
}, | ||
"servers": [{"url": "/"}], | ||
"paths": { | ||
"/bar": { | ||
"get": { | ||
"summary": "Bar", | ||
"operationId": "bar_bar_get", | ||
"responses": { | ||
"200": { | ||
"description": "Successful response", | ||
"content": {"application/json": {"schema": {"type": "string"}}}, | ||
} | ||
}, | ||
"deprecated": False, | ||
} | ||
} | ||
}, | ||
} |