Skip to content

Commit

Permalink
Improved code coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
mauler committed Mar 1, 2016
1 parent 7a78c45 commit 9fc9f4f
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 6 deletions.
34 changes: 28 additions & 6 deletions tests/test_apidocjs.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
import sys
import unittest

# sys.path.append("demos/helloworld")
# # from helloworld.api import PostIt
# import helloworld

from tornado.testing import AsyncHTTPTestCase
sys.path.append(".")
from tornado_json.apidocjs.output import Notation
from tornado_json.apidocjs.output import format_field_name
Expand All @@ -15,8 +12,33 @@
from tornado_json.apidocjs.output import get_schema_nested
from tornado_json.apidocjs.output import get_output_example_doc
from tornado_json.apidocjs.output import get_output_schema_doc
# from tornado_json.apidocjs.output import generate_apidoc_skeleton
# from tornado_json.routes import get_routes
from tornado_json.apidocjs.output import generate_apidoc_skeleton
from tornado_json.routes import get_routes
from tornado_json import application
sys.path.append("demos/helloworld")
import helloworld


class TestGenerateApidocSkeleton(AsyncHTTPTestCase):
def get_app(self):
rts = get_routes(helloworld)
return application.Application(
routes=rts,
settings={"debug": True},
db_conn=None,
apidocjs={
"name": "Helloworld Project API",
"version": "1.0.0",
"title": "Hellword API",
"url": "https://api.helloworld.com/v1"
}
)

def test_generate_apidoc_skeleton(self):
self.assertTrue(
generate_apidoc_skeleton(
self._app.named_handlers,
**self._app.apidocjs))


class TestGeneratePySource(unittest.TestCase):
Expand Down
2 changes: 2 additions & 0 deletions tornado_json/apidocjs/output.py
Original file line number Diff line number Diff line change
Expand Up @@ -527,3 +527,5 @@ def generate_apidoc_skeleton(routes,

system("apidoc -i %s -o %s --verbose --line-ending=LF" %
(content_output_path, doc_output_path))

return True
1 change: 1 addition & 0 deletions tornado_json/application.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ class Application(tornado.web.Application):
def __init__(self, routes, settings, db_conn=None,
generate_docs=False, apidocjs=None):

self.apidocjs = apidocjs
if apidocjs:
generate_apidoc_skeleton(routes, **apidocjs)

Expand Down

0 comments on commit 9fc9f4f

Please sign in to comment.