This repository has been archived by the owner on Mar 24, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #25 from lendingblock/master
Release 0.1.5
- Loading branch information
Showing
11 changed files
with
111 additions
and
32 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,6 +16,7 @@ dist | |
# ides | ||
.vscode/.ropeproject | ||
.idea | ||
*.swp | ||
|
||
# Mac | ||
.DS_Store | ||
|
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 |
---|---|---|
@@ -1,3 +1,3 @@ | ||
"""Minimal OpenAPI asynchronous server application | ||
""" | ||
__version__ = '0.1.4' | ||
__version__ = '0.1.5' |
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
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,48 @@ | ||
from dataclasses import asdict | ||
|
||
from openapi.spec import OpenApi, OpenApiSpec | ||
from openapi.testing import jsonBody | ||
|
||
|
||
async def test_spec(test_app): | ||
open_api = OpenApi() | ||
|
||
spec = OpenApiSpec(asdict(open_api)) | ||
spec.build(test_app) | ||
assert spec.schemas['TaskQuery']['properties'].keys() == { | ||
'done', | ||
'severity', | ||
'severity:lt', | ||
'severity:gt' | ||
} | ||
|
||
|
||
async def test_filters(cli, clean_db): | ||
test1 = { | ||
'title': 'test1', | ||
'severity': 1 | ||
} | ||
test2 = { | ||
'title': 'test2', | ||
'severity': 3 | ||
} | ||
test3 = { | ||
'title': 'test3' | ||
} | ||
|
||
await cli.post('/tasks', json=test1) | ||
await cli.post('/tasks', json=test2) | ||
await cli.post('/tasks', json=test3) | ||
|
||
async def assert_query(params, expected): | ||
response = await cli.get('/tasks', params=params) | ||
body = await jsonBody(response, 200) | ||
for d in body: | ||
d.pop('id') | ||
assert body == expected | ||
|
||
await assert_query({'severity:gt': 2}, [test2]) | ||
await assert_query({'severity:lt': 2}, [test1]) | ||
await assert_query({'severity': 2}, []) | ||
await assert_query({'severity': 1}, [test1]) | ||
await assert_query({'severity': 'NULL'}, [test3]) |