-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test(tests/test_case.py): add test case
- Loading branch information
Showing
9 changed files
with
102 additions
and
45 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 |
---|---|---|
@@ -0,0 +1,5 @@ | ||
[run] | ||
omit = | ||
*/venv/* | ||
*/virtualenv/* | ||
*/tests/* |
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 |
---|---|---|
|
@@ -5,7 +5,7 @@ | |
Program: | ||
Flask-Docs | ||
Version: | ||
0.1.7 | ||
0.1.8 | ||
History: | ||
Created on 2018/05/20 | ||
Last modified on 2020/10/18 | ||
|
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 was deleted.
Oops, something went wrong.
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,91 @@ | ||
#!/usr/bin/env python | ||
# coding=utf8 | ||
|
||
''' | ||
Program: | ||
Test case | ||
Version: | ||
0.0.2 | ||
History: | ||
Created on 2020/10/18 | ||
Last modified on 2020/10/18 | ||
Author: | ||
kwkw | ||
''' | ||
|
||
|
||
import sys | ||
sys.path.append('.') | ||
|
||
import unittest | ||
from flask import Flask, Blueprint | ||
from flask_restful import Resource, Api | ||
from flask_docs import ApiDoc | ||
|
||
|
||
app = Flask(__name__) | ||
app.config['API_DOC_MEMBER'] = ['api'] | ||
ApiDoc(app, title='Test App') | ||
|
||
|
||
class AcceptTestCase(unittest.TestCase): | ||
|
||
def test_accept_docs_api(self): | ||
|
||
with app.test_client() as client: | ||
res = client.get('/docs/api/') | ||
self.assertEqual(res.status_code, 200) | ||
self.assertEqual(res.content_type, 'text/html; charset=utf-8') | ||
|
||
|
||
class RestfulApiTestRoute(Resource): | ||
pass | ||
|
||
|
||
class TodoList(RestfulApiTestRoute): | ||
"""Manage todolist""" | ||
|
||
def post(self): | ||
"""Submission of data""" | ||
pass | ||
|
||
def get(self): | ||
""" | ||
@@@ | ||
### markdown | ||
@@@ | ||
""" | ||
pass | ||
|
||
|
||
class CoverageTestCase(unittest.TestCase): | ||
|
||
def test_api_route_coverage(self): | ||
|
||
api = Blueprint('api', __name__) | ||
|
||
@api.route('/add_data', methods=['POST']) | ||
@api.route('/data', methods=['POST', 'GET']) | ||
def add_data(): | ||
pass | ||
|
||
app.register_blueprint(api, url_prefix='/api') | ||
|
||
with app.test_client() as client: | ||
res = client.get('/docs/api/') | ||
self.assertEqual(res.status_code, 200) | ||
self.assertEqual(res.content_type, 'text/html; charset=utf-8') | ||
|
||
def test_restful_api_route_coverage(self): | ||
|
||
restful_api = Api(app) | ||
restful_api.add_resource(TodoList, '/todolist', '/todo') | ||
|
||
with app.test_client() as client: | ||
res = client.get('/docs/api/') | ||
self.assertEqual(res.status_code, 200) | ||
self.assertEqual(res.content_type, 'text/html; charset=utf-8') | ||
|
||
|
||
if __name__ == '__main__': | ||
unittest.main() |