Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dont document inclusion of self argument, add tests verifying how att… #83

Merged
merged 1 commit into from
Oct 11, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions hug/documentation.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ def generate(module, base_url="", api_version=None):
parameters = [param for param in handler.accepted_parameters if not param in ('request',
'response')
and not param.startswith('hug_')
and not param == 'self'
and not hasattr(param, 'directive')]
if parameters:
inputs = doc.setdefault('inputs', OrderedDict())
Expand Down
28 changes: 28 additions & 0 deletions tests/test_decorators.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,34 @@ def hello_world():
assert hug.test.get(api, '/hello_world').data == "Hello World!"


def test_basic_call_on_method():
'''Test to ensure the most basic call still works if applied to a method'''
class API(object):

@hug.call()
def hello_world(self=None):
return "Hello World!"

api_instance = API()
assert api_instance.hello_world.interface
assert api_instance.hello_world() == 'Hello World!'
assert hug.test.get(api, '/hello_world').data == "Hello World!"

class API(object):

def hello_world(self):
return "Hello World!"

api_instance = API()

@hug.call()
def hello_world():
return api_instance.hello_world()

assert api_instance.hello_world() == 'Hello World!'
assert hug.test.get(api, '/hello_world').data == "Hello World!"


def test_single_parameter():
'''Test that an api with a single parameter interacts as desired'''
@hug.call()
Expand Down