Skip to content

Commit

Permalink
Add FreeWilledHandler
Browse files Browse the repository at this point in the history
  • Loading branch information
hfaran committed Feb 17, 2014
1 parent 197d452 commit 6a19815
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 2 deletions.
1 change: 1 addition & 0 deletions .travis.yml
Expand Up @@ -8,6 +8,7 @@ install:
- "pip install pytest-cov"
- "pip install coverage"
- "pip install coveralls"
- "pip install mock"
script:
coverage run --source=tornado_json setup.py test
after_success:
Expand Down
12 changes: 12 additions & 0 deletions demos/helloworld/helloworld/api.py
Expand Up @@ -127,3 +127,15 @@ class Greeting(APIHandler):
@io_schema
def get(self, name):
return "Greetings, {}!".format(name)


class FreeWilledHandler(APIHandler):

# And of course, you aren't forced to use schema validation;
# if you want your handlers to do something more custom,
# they definitely can.
def get(self):
self.success("I don't need no stinkin' schema validation.")
# If you're feeling really bold, you could even skip JSend
# altogether and do the following EVIL thing:
# self.write("I'm writing back a string that isn't JSON! Take that!")
3 changes: 3 additions & 0 deletions tornado_json/test/func_test.py
@@ -1,13 +1,15 @@
import sys
import json
from tornado.testing import AsyncHTTPTestCase
from mock import Mock

try:
sys.path.append('.')
from tornado_json import routes
from tornado_json import utils
from tornado_json import jsend
from tornado_json import application
from tornado_json import requesthandlers
sys.path.append('demos/helloworld')
import helloworld
except ImportError as e:
Expand All @@ -29,6 +31,7 @@ def get_app(self):
return application.Application(
routes=routes.get_routes(helloworld),
settings={},
db_conn=Mock()
)

def test_synchronous_handler(self):
Expand Down
6 changes: 4 additions & 2 deletions tornado_json/test/test_tornado_json.py
Expand Up @@ -51,7 +51,8 @@ def test_get_routes(self):
("/api/asynchelloworld", helloworld.api.AsyncHelloWorld),
("/api/postit", helloworld.api.PostIt),
("/api/greeting/(?P<name>[a-zA-Z0-9_]+)/?$",
helloworld.api.Greeting)
helloworld.api.Greeting),
("/api/freewilled", helloworld.api.FreeWilledHandler)
])

def test_gen_submodule_names(self):
Expand All @@ -67,7 +68,8 @@ def test_get_module_routes(self):
("/api/asynchelloworld", helloworld.api.AsyncHelloWorld),
("/api/postit", helloworld.api.PostIt),
("/api/greeting/(?P<name>[a-zA-Z0-9_]+)/?$",
helloworld.api.Greeting)
helloworld.api.Greeting),
("/api/freewilled", helloworld.api.FreeWilledHandler)
])


Expand Down

0 comments on commit 6a19815

Please sign in to comment.