Skip to content

Commit

Permalink
#101 test resolving of method and classmethod
Browse files Browse the repository at this point in the history
  • Loading branch information
hjacobs committed Dec 5, 2015
1 parent 7ad368c commit b194539
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 0 deletions.
8 changes: 8 additions & 0 deletions tests/fakeapi/api.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -547,6 +547,14 @@ paths:
description: Name of the person to say good evening.
required: true
type: string
/resolver-test/method:
get:
summary: Test class instance method
operationId: fakeapi.hello.class_instance.test_method
/resolver-test/classmethod:
get:
summary: Test class instance method
operationId: fakeapi.hello.DummyClass.test_classmethod
definitions:
new_stack:
type: object
Expand Down
11 changes: 11 additions & 0 deletions tests/fakeapi/hello.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,17 @@
from connexion import NoContent


class DummyClass:
@classmethod
def test_classmethod(cls):
return cls.__name__

def test_method(self):
return self.__class__.__name__

class_instance = DummyClass()


def post_greeting(name):
data = {'greeting': 'Hello {name}'.format(name=name)}
return data
Expand Down
12 changes: 12 additions & 0 deletions tests/test_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -511,3 +511,15 @@ def test_test_schema_int(app):
assert array_request.content_type == 'application/json'
array_response = json.loads(array_request.data.decode()) # type: list
assert array_response == 42


def test_resolve_method(app):
app_client = app.app.test_client()
resp = app_client.get('/v1.0/resolver-test/method') # type: flask.Response
assert resp.data.decode() == '"DummyClass"'


def test_resolve_classmethod(app):
app_client = app.app.test_client()
resp = app_client.get('/v1.0/resolver-test/classmethod') # type: flask.Response
assert resp.data.decode() == '"DummyClass"'

0 comments on commit b194539

Please sign in to comment.