Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
Flask API 를 테스트하기 위한 아이디어
# 실제 API
def get_collections(serializer):
collections =
paging =
return serializer.serialize(items=collections, paging=paging)
# 테스트
def test_serializer_get_collections():
collections = fixture_collections()
paging = fixture_paging()
serializer = ListSerializer()
result = serializer.serialize(items=collections, paging=paging)
assert_equal(len(result['items']), 3)
def test_api_get_collections():
serializer = StubListSerializer()
assert_equal(len(serializer.executions['serialize']), 1)
class StubListSerializer(object):
executions = {}
def serialize(items, paging):
executions.setdefault('serialize', [])
executions['serialize'].append((items, paging))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment