Browse Source

fixed the api listing

master
Julio Biason 11 years ago
parent
commit
9498c9d832
  1. 10
      luncho/server.py
  2. 2
      tests/index_tests.py

10
luncho/server.py

@ -6,8 +6,6 @@ import json
import hmac import hmac
import datetime import datetime
from operator import itemgetter
from flask import Flask from flask import Flask
from flask import jsonify from flask import jsonify
@ -212,12 +210,16 @@ def show_api():
summary = ' '.join(line.strip() for line in summary.split('\n')) summary = ' '.join(line.strip() for line in summary.split('\n'))
for method in rule.methods: for method in rule.methods:
if method not in ['GET', 'POST', 'PUT', 'DELETE']:
# other methods are not required
continue
routes.append([ routes.append([
rule.methods.upper() + ' ' + path, method.upper() + ' ' + path,
summary summary
]) ])
routes.sort(key=itemgetter(0)) routes.sort(key=lambda url: url[0].split()[1])
return jsonify(status='OK', api=routes) return jsonify(status='OK', api=routes)

2
tests/index_tests.py

@ -22,7 +22,7 @@ class TestIndex(LunchoTests):
self.assertJsonOk(rv) self.assertJsonOk(rv)
response = json.loads(rv.data) response = json.loads(rv.data)
self.assertEqual(response['api'][0][0], '/') self.assertEqual(response['api'][0][0], 'GET /')
if __name__ == '__main__': if __name__ == '__main__':
unittest.main() unittest.main()

Loading…
Cancel
Save