From 62ea912469f69ad2bf634b144428b16e4a691986 Mon Sep 17 00:00:00 2001 From: Alex Date: Mon, 2 Oct 2017 16:02:06 -0400 Subject: [PATCH 1/7] Beginning conversion into a blueprint model to allow scalability of api --- apiwrapper/PittAPI | 2 +- apiwrapper/__init__.py | 17 ++++++++++++ apiwrapper/v0/__init__.py | 3 +++ apiwrapper/{ => v0}/views.py | 51 ++++++++++++++++++------------------ server.py | 6 +++-- tests/test_api.py | 4 ++- 6 files changed, 54 insertions(+), 29 deletions(-) create mode 100644 apiwrapper/__init__.py create mode 100644 apiwrapper/v0/__init__.py rename apiwrapper/{ => v0}/views.py (76%) diff --git a/apiwrapper/PittAPI b/apiwrapper/PittAPI index 13056f1..c1bf27e 160000 --- a/apiwrapper/PittAPI +++ b/apiwrapper/PittAPI @@ -1 +1 @@ -Subproject commit 13056f1ddae2ba3c5d97fa0ba294368bfe98d07b +Subproject commit c1bf27e754607083d609cc6c73195f9fce95fb94 diff --git a/apiwrapper/__init__.py b/apiwrapper/__init__.py new file mode 100644 index 0000000..c063963 --- /dev/null +++ b/apiwrapper/__init__.py @@ -0,0 +1,17 @@ +from flask import Flask +from flask_restful import Api +from flask_cors import CORS + +cors = CORS() +restful_api = Api() + +def create_app(): + app = Flask(__name__) + + cors.init_app(app) + restful_api.init_app(app) + + from .v0 import rest_api as api_v0 + app.register_blueprint(api_v0, url_prefix='/v0') + + return app \ No newline at end of file diff --git a/apiwrapper/v0/__init__.py b/apiwrapper/v0/__init__.py new file mode 100644 index 0000000..bf2b62b --- /dev/null +++ b/apiwrapper/v0/__init__.py @@ -0,0 +1,3 @@ +from flask import Blueprint + +rest_api = Blueprint('rest_api', __name__) diff --git a/apiwrapper/views.py b/apiwrapper/v0/views.py similarity index 76% rename from apiwrapper/views.py rename to apiwrapper/v0/views.py index 35b72e1..3ffa3f2 100644 --- a/apiwrapper/views.py +++ b/apiwrapper/v0/views.py @@ -15,17 +15,14 @@ with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. ''' -from flask import Flask, make_response -from flask_restful import Api, Resource -from flask_cors import CORS, cross_origin -from .PittAPI.PittAPI import course, lab, laundry, people, shuttle, textbook, news +from flask import make_response +from flask_restful import Resource +from apiwrapper.PittAPI.PittAPI import course, lab, laundry, people, shuttle, textbook, news +from apiwrapper.v0 import rest_api import json -app = Flask(__name__) -CORS(app) -api = Api(app) -@api.representation('application/json') +@rest_api.representation('application/json') def output_json(data, code, headers=None): """Makes a Flask response with a JSON encoded body""" resp = make_response(json.dumps(data), code) @@ -33,7 +30,7 @@ def output_json(data, code, headers=None): return resp -@app.errorhandler(404) +@rest_api.errorhandler(404) def page_not_found(e): return output_json({'error': 'Invalid request'}, 404) @@ -85,6 +82,7 @@ def get(self, query): except Exception as e: return {'error': str(e)} + class TextbookAPI(Resource): def get(self, department_code, course_name, instructor, term): try: @@ -92,6 +90,7 @@ def get(self, department_code, course_name, instructor, term): except Exception as e: return {'error': str(e)} + class TextbookNoTermAPI(Resource): def get(self, department_code, course_name, instructor, term='2600'): try: @@ -99,6 +98,7 @@ def get(self, department_code, course_name, instructor, term='2600'): except Exception as e: return {'error': str(e)} + class ShuttleRoutesAPI(Resource): def get(self): try: @@ -106,6 +106,7 @@ def get(self): except Exception as e: return {'error': str(e)} + class ShuttleVehiclePointsAPI(Resource): def get(self): try: @@ -113,6 +114,7 @@ def get(self): except Exception as e: return {'error': str(e)} + class ShuttleStopArrivalsAPI(Resource): def get(self, times_per_stop=1): try: @@ -120,6 +122,7 @@ def get(self, times_per_stop=1): except Exception as e: return {'error': str(e)} + class ShuttleStopEstimatesAPI(Resource): def get(self, vehicle_id, quantity=2): try: @@ -127,6 +130,7 @@ def get(self, vehicle_id, quantity=2): except Exception as e: return {'error': str(e)} + class NewsAPI(Resource): def get(self, feed, max_news_items): try: @@ -136,19 +140,16 @@ def get(self, feed, max_news_items): return {'error': str(e)} -api.add_resource(CourseGetAPI, '/courses//') -api.add_resource(ClassAPI, '/class//') -api.add_resource(LabStatusAPI, '/lab_status/') -api.add_resource(LaundryStatusAPI, '/laundry/simple/') -api.add_resource(LaundryStatusDetailedAPI, '/laundry/detailed/') -api.add_resource(PeopleAPI, '/people/') -api.add_resource(ShuttleRoutesAPI, '/shuttle/routes') -api.add_resource(ShuttleVehiclePointsAPI, '/shuttle/points') -api.add_resource(ShuttleStopArrivalsAPI, '/shuttle/arrivals/') -api.add_resource(ShuttleStopEstimatesAPI, '/shuttle/estimates//') -api.add_resource(TextbookAPI, '/textbook////') -api.add_resource(TextbookNoTermAPI, '/textbook////') -api.add_resource(NewsAPI, '/news//') - -if __name__ is '__main__': - app.run(debug=True, port=8000) +rest_api.add_resource(CourseGetAPI, '/courses//') +rest_api.add_resource(ClassAPI, '/class//') +rest_api.add_resource(LabStatusAPI, '/lab_status/') +rest_api.add_resource(LaundryStatusAPI, '/laundry/simple/') +rest_api.add_resource(LaundryStatusDetailedAPI, '/laundry/detailed/') +rest_api.add_resource(PeopleAPI, '/people/') +rest_api.add_resource(ShuttleRoutesAPI, '/shuttle/routes') +rest_api.add_resource(ShuttleVehiclePointsAPI, '/shuttle/points') +rest_api.add_resource(ShuttleStopArrivalsAPI, '/shuttle/arrivals/') +rest_api.add_resource(ShuttleStopEstimatesAPI, '/shuttle/estimates//') +rest_api.add_resource(TextbookAPI, '/textbook////') +rest_api.add_resource(TextbookNoTermAPI, '/textbook////') +rest_api.add_resource(NewsAPI, '/news//') diff --git a/server.py b/server.py index 056a1b3..3fe62fe 100644 --- a/server.py +++ b/server.py @@ -15,6 +15,8 @@ with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. ''' -from apiwrapper.views import app +from apiwrapper import create_app -app.run(host="0.0.0.0", port=5000) +app = create_app() +# TODO revert to 0.0.0.0 +app.run(host="127.0.0.1", port=5000) diff --git a/tests/test_api.py b/tests/test_api.py index 133c288..a38c80d 100644 --- a/tests/test_api.py +++ b/tests/test_api.py @@ -16,9 +16,11 @@ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. ''' -from apiwrapper.views import app import unittest +from apiwrapper.v0.views import app + + class APITest(unittest.TestCase): def setUp(self): self.app = app.test_client() From 78f4255a67fd5273810f7600bfe52a6195b8e91d Mon Sep 17 00:00:00 2001 From: Alex Zharichenko Date: Tue, 19 Dec 2017 21:46:46 -0500 Subject: [PATCH 2/7] Committing current state of changes --- apiwrapper/__init__.py | 8 +++----- apiwrapper/v0/__init__.py | 4 +++- server.py | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/apiwrapper/__init__.py b/apiwrapper/__init__.py index c063963..511df7f 100644 --- a/apiwrapper/__init__.py +++ b/apiwrapper/__init__.py @@ -1,17 +1,15 @@ from flask import Flask -from flask_restful import Api from flask_cors import CORS cors = CORS() -restful_api = Api() + def create_app(): app = Flask(__name__) cors.init_app(app) - restful_api.init_app(app) - from .v0 import rest_api as api_v0 - app.register_blueprint(api_v0, url_prefix='/v0') + from .v0 import restapi_blue + app.register_blueprint(restapi_blue) return app \ No newline at end of file diff --git a/apiwrapper/v0/__init__.py b/apiwrapper/v0/__init__.py index bf2b62b..9273c1a 100644 --- a/apiwrapper/v0/__init__.py +++ b/apiwrapper/v0/__init__.py @@ -1,3 +1,5 @@ from flask import Blueprint +from flask_restful import Api -rest_api = Blueprint('rest_api', __name__) +restapi_blue = Blueprint('rest_api', __name__) +rest_api = Api(restapi_blue) diff --git a/server.py b/server.py index 3fe62fe..22382ae 100644 --- a/server.py +++ b/server.py @@ -19,4 +19,4 @@ app = create_app() # TODO revert to 0.0.0.0 -app.run(host="127.0.0.1", port=5000) +app.run(host="127.0.0.1", port=5000, debug=True) From b85455c37440ac2e2af7dff54f7fe5d115d2316e Mon Sep 17 00:00:00 2001 From: Alex Date: Tue, 19 Dec 2017 23:53:24 -0500 Subject: [PATCH 3/7] Implemented blueprints and added simple function for pulling all classes into API --- apiwrapper/__init__.py | 10 +++-- apiwrapper/v0/__init__.py | 21 ++++++++++ apiwrapper/v0/views.py | 82 +++++++++++++++++++-------------------- 3 files changed, 67 insertions(+), 46 deletions(-) diff --git a/apiwrapper/__init__.py b/apiwrapper/__init__.py index 511df7f..251fb0f 100644 --- a/apiwrapper/__init__.py +++ b/apiwrapper/__init__.py @@ -1,6 +1,8 @@ from flask import Flask from flask_cors import CORS +from apiwrapper.v0 import restapi_blue + cors = CORS() @@ -9,7 +11,7 @@ def create_app(): cors.init_app(app) - from .v0 import restapi_blue - app.register_blueprint(restapi_blue) - - return app \ No newline at end of file + app.register_blueprint(restapi_blue, + url_prefix='/v{version}'.format( + version=0)) + return app diff --git a/apiwrapper/v0/__init__.py b/apiwrapper/v0/__init__.py index 9273c1a..9097610 100644 --- a/apiwrapper/v0/__init__.py +++ b/apiwrapper/v0/__init__.py @@ -1,5 +1,26 @@ +""" +Web Wrapper for PittAPI, web app for REST endpoints for the PittAPI +Copyright (C) 2015 Ritwik Gupta + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or +(at your option) any later version. +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License along +with this program; if not, write to the Free Software Foundation, Inc., +51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +""" from flask import Blueprint from flask_restful import Api +from apiwrapper.v0.views import add_resources + restapi_blue = Blueprint('rest_api', __name__) rest_api = Api(restapi_blue) + +add_resources() diff --git a/apiwrapper/v0/views.py b/apiwrapper/v0/views.py index 3ffa3f2..006b469 100644 --- a/apiwrapper/v0/views.py +++ b/apiwrapper/v0/views.py @@ -1,4 +1,4 @@ -''' +""" Web Wrapper for PittAPI, web app for REST endpoints for the PittAPI Copyright (C) 2015 Ritwik Gupta @@ -14,28 +14,18 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. -''' -from flask import make_response -from flask_restful import Resource -from apiwrapper.PittAPI.PittAPI import course, lab, laundry, people, shuttle, textbook, news -from apiwrapper.v0 import rest_api -import json - - -@rest_api.representation('application/json') -def output_json(data, code, headers=None): - """Makes a Flask response with a JSON encoded body""" - resp = make_response(json.dumps(data), code) - resp.headers.extend(headers or {}) - return resp +""" +import inspect +import sys +from flask_restful import Resource -@rest_api.errorhandler(404) -def page_not_found(e): - return output_json({'error': 'Invalid request'}, 404) +from apiwrapper.PittAPI.PittAPI import course, lab, laundry, people, shuttle, textbook, news class CourseGetAPI(Resource): + PATH = '/courses//' + def get(self, term, code): try: return course.get_courses(term, code) @@ -44,6 +34,8 @@ def get(self, term, code): class ClassAPI(Resource): + PATH = '/class//' + def get(self, term, class_number): try: return course.get_class(term, class_number) @@ -52,6 +44,8 @@ def get(self, term, class_number): class LabStatusAPI(Resource): + PATH = '/lab_status/' + def get(self, lab_name): try: return lab.get_status(lab_name) @@ -60,6 +54,8 @@ def get(self, lab_name): class LaundryStatusAPI(Resource): + PATH = '/laundry/simple/' + def get(self, location): try: return laundry.get_status_simple(location) @@ -68,6 +64,8 @@ def get(self, location): class LaundryStatusDetailedAPI(Resource): + PATH = '/laundry/detailed/' + def get(self, location): try: return laundry.get_status_detailed(location) @@ -76,6 +74,8 @@ def get(self, location): class PeopleAPI(Resource): + PATH = '/people/' + def get(self, query): try: return people.get_person(query) @@ -84,22 +84,19 @@ def get(self, query): class TextbookAPI(Resource): - def get(self, department_code, course_name, instructor, term): - try: - return textbook.get_books_data([{'department_code': department_code, 'course_name': course_name, 'instructor': instructor, 'term': term}]) - except Exception as e: - return {'error': str(e)} - + PATH = '/textbook////' -class TextbookNoTermAPI(Resource): - def get(self, department_code, course_name, instructor, term='2600'): + def get(self, department_code, course_name, instructor, term): try: - return textbook.get_books_data([{'department_code': department_code, 'course_name': course_name, 'instructor': instructor, 'term': term}]) + return textbook.get_books_data([{'department_code': department_code, 'course_name': course_name, + 'instructor': instructor, 'term': term}]) except Exception as e: return {'error': str(e)} class ShuttleRoutesAPI(Resource): + PATH = '/shuttle/routes' + def get(self): try: return shuttle.get_routes() @@ -108,6 +105,8 @@ def get(self): class ShuttleVehiclePointsAPI(Resource): + PATH = '/shuttle/points' + def get(self): try: return shuttle.get_map_vehicle_points() @@ -116,14 +115,18 @@ def get(self): class ShuttleStopArrivalsAPI(Resource): + PATH = '/shuttle/arrivals/' + def get(self, times_per_stop=1): try: - return shuttle.get_route_stop_arrivals("8882812681",times_per_stop) + return shuttle.get_route_stop_arrivals("8882812681", times_per_stop) except Exception as e: return {'error': str(e)} class ShuttleStopEstimatesAPI(Resource): + PATH = '/shuttle/estimates//' + def get(self, vehicle_id, quantity=2): try: return shuttle.get_vehicle_route_stop_estimates(vehicle_id, quantity) @@ -131,7 +134,9 @@ def get(self, vehicle_id, quantity=2): return {'error': str(e)} -class NewsAPI(Resource): +class News(Resource): + PATH = '/news//' + def get(self, feed, max_news_items): try: max_news_items = int(max_news_items) @@ -140,16 +145,9 @@ def get(self, feed, max_news_items): return {'error': str(e)} -rest_api.add_resource(CourseGetAPI, '/courses//') -rest_api.add_resource(ClassAPI, '/class//') -rest_api.add_resource(LabStatusAPI, '/lab_status/') -rest_api.add_resource(LaundryStatusAPI, '/laundry/simple/') -rest_api.add_resource(LaundryStatusDetailedAPI, '/laundry/detailed/') -rest_api.add_resource(PeopleAPI, '/people/') -rest_api.add_resource(ShuttleRoutesAPI, '/shuttle/routes') -rest_api.add_resource(ShuttleVehiclePointsAPI, '/shuttle/points') -rest_api.add_resource(ShuttleStopArrivalsAPI, '/shuttle/arrivals/') -rest_api.add_resource(ShuttleStopEstimatesAPI, '/shuttle/estimates//') -rest_api.add_resource(TextbookAPI, '/textbook////') -rest_api.add_resource(TextbookNoTermAPI, '/textbook////') -rest_api.add_resource(NewsAPI, '/news//') +def add_resources(): + from apiwrapper.v0 import rest_api + clsmembers = inspect.getmembers(sys.modules[__name__], inspect.isclass) + clsmembers = [cls[1] for cls in clsmembers if cls[0] != 'Resource'] + for cls in clsmembers: + rest_api.add_resource(cls, cls.PATH) From 7c91ce5612e3d5f3bf90de7f1579e19b39943f29 Mon Sep 17 00:00:00 2001 From: Alex Date: Tue, 19 Dec 2017 23:55:27 -0500 Subject: [PATCH 4/7] Removed API from all resources since they don't accurate reflect entire APIs in PittAPI --- apiwrapper/v0/views.py | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/apiwrapper/v0/views.py b/apiwrapper/v0/views.py index 006b469..663d106 100644 --- a/apiwrapper/v0/views.py +++ b/apiwrapper/v0/views.py @@ -23,7 +23,7 @@ from apiwrapper.PittAPI.PittAPI import course, lab, laundry, people, shuttle, textbook, news -class CourseGetAPI(Resource): +class CourseGet(Resource): PATH = '/courses//' def get(self, term, code): @@ -33,7 +33,7 @@ def get(self, term, code): return {'error': str(e)} -class ClassAPI(Resource): +class Class(Resource): PATH = '/class//' def get(self, term, class_number): @@ -43,7 +43,7 @@ def get(self, term, class_number): return {'error': str(e)} -class LabStatusAPI(Resource): +class LabStatus(Resource): PATH = '/lab_status/' def get(self, lab_name): @@ -53,7 +53,7 @@ def get(self, lab_name): return {'error': str(e)} -class LaundryStatusAPI(Resource): +class LaundryStatus(Resource): PATH = '/laundry/simple/' def get(self, location): @@ -63,7 +63,7 @@ def get(self, location): return {'error': str(e)} -class LaundryStatusDetailedAPI(Resource): +class LaundryStatusDetailed(Resource): PATH = '/laundry/detailed/' def get(self, location): @@ -73,7 +73,7 @@ def get(self, location): return {'error': str(e)} -class PeopleAPI(Resource): +class People(Resource): PATH = '/people/' def get(self, query): @@ -83,7 +83,7 @@ def get(self, query): return {'error': str(e)} -class TextbookAPI(Resource): +class Textbook(Resource): PATH = '/textbook////' def get(self, department_code, course_name, instructor, term): @@ -94,7 +94,7 @@ def get(self, department_code, course_name, instructor, term): return {'error': str(e)} -class ShuttleRoutesAPI(Resource): +class ShuttleRoutes(Resource): PATH = '/shuttle/routes' def get(self): @@ -104,7 +104,7 @@ def get(self): return {'error': str(e)} -class ShuttleVehiclePointsAPI(Resource): +class ShuttleVehiclePoints(Resource): PATH = '/shuttle/points' def get(self): @@ -114,7 +114,7 @@ def get(self): return {'error': str(e)} -class ShuttleStopArrivalsAPI(Resource): +class ShuttleStopArrivals(Resource): PATH = '/shuttle/arrivals/' def get(self, times_per_stop=1): @@ -124,7 +124,7 @@ def get(self, times_per_stop=1): return {'error': str(e)} -class ShuttleStopEstimatesAPI(Resource): +class ShuttleStopEstimates(Resource): PATH = '/shuttle/estimates//' def get(self, vehicle_id, quantity=2): From 05951aa3d4d8735ecc4d21cacb35f7e2557e6b2e Mon Sep 17 00:00:00 2001 From: Alex Date: Wed, 20 Dec 2017 00:25:12 -0500 Subject: [PATCH 5/7] Change name of blueprint to apiv0 and added license in files --- apiwrapper/__init__.py | 25 +++++++++++++++++++------ apiwrapper/v0/__init__.py | 4 ++-- apiwrapper/v0/views.py | 4 ++-- server.py | 7 +++---- 4 files changed, 26 insertions(+), 14 deletions(-) diff --git a/apiwrapper/__init__.py b/apiwrapper/__init__.py index 251fb0f..516fa5d 100644 --- a/apiwrapper/__init__.py +++ b/apiwrapper/__init__.py @@ -1,17 +1,30 @@ +""" +Web Wrapper for PittAPI, web app for REST endpoints for the PittAPI +Copyright (C) 2015 Ritwik Gupta + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or +(at your option) any later version. +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License along +with this program; if not, write to the Free Software Foundation, Inc., +51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +""" from flask import Flask from flask_cors import CORS -from apiwrapper.v0 import restapi_blue +from apiwrapper.v0 import apiv0_bp cors = CORS() def create_app(): app = Flask(__name__) - cors.init_app(app) - - app.register_blueprint(restapi_blue, - url_prefix='/v{version}'.format( - version=0)) + app.register_blueprint(apiv0_bp, url_prefix='/v0') return app diff --git a/apiwrapper/v0/__init__.py b/apiwrapper/v0/__init__.py index 9097610..6a77434 100644 --- a/apiwrapper/v0/__init__.py +++ b/apiwrapper/v0/__init__.py @@ -20,7 +20,7 @@ from apiwrapper.v0.views import add_resources -restapi_blue = Blueprint('rest_api', __name__) -rest_api = Api(restapi_blue) +apiv0_bp = Blueprint('rest_api', __name__) +apiv0 = Api(apiv0_bp) add_resources() diff --git a/apiwrapper/v0/views.py b/apiwrapper/v0/views.py index 663d106..90f7c9e 100644 --- a/apiwrapper/v0/views.py +++ b/apiwrapper/v0/views.py @@ -146,8 +146,8 @@ def get(self, feed, max_news_items): def add_resources(): - from apiwrapper.v0 import rest_api + from apiwrapper.v0 import apiv0 clsmembers = inspect.getmembers(sys.modules[__name__], inspect.isclass) clsmembers = [cls[1] for cls in clsmembers if cls[0] != 'Resource'] for cls in clsmembers: - rest_api.add_resource(cls, cls.PATH) + apiv0.add_resource(cls, cls.PATH) diff --git a/server.py b/server.py index 22382ae..dbeb86f 100644 --- a/server.py +++ b/server.py @@ -1,4 +1,4 @@ -''' +""" Web Wrapper for PittAPI, web app for REST endpoints for the PittAPI Copyright (C) 2015 Ritwik Gupta @@ -14,9 +14,8 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. -''' +""" from apiwrapper import create_app app = create_app() -# TODO revert to 0.0.0.0 -app.run(host="127.0.0.1", port=5000, debug=True) +app.run(host="0.0.0.0", port=5000) From a164a35e9b0ac05c7463232960fe65485ae75136 Mon Sep 17 00:00:00 2001 From: Alex Date: Wed, 20 Dec 2017 00:34:28 -0500 Subject: [PATCH 6/7] Changed endpoints in README to reflect changes --- README.md | 25 ++++++++++--------------- 1 file changed, 10 insertions(+), 15 deletions(-) diff --git a/README.md b/README.md index 27b5d1c..819fd4d 100644 --- a/README.md +++ b/README.md @@ -15,44 +15,44 @@ #### Courses ``` -/courses// +/v0/courses// ``` #### Classes ``` -/class// +/v0/class// ``` #### Lab Status ``` -/lab_status/ +/v0/lab_status/ ``` #### Laundry Status For simple laundry status: ``` -/laundry/simple/ +/v0/laundry/simple/ ``` For detailed laundry status: ``` -/laundry/detailed/ +/v0/laundry/detailed/ ``` #### People ``` -/people/ +/v0/people/ ``` #### Shuttles For shuttle routes: ``` -/shuttle/routes +/v0/shuttle/routes ``` For shuttle vehicle points: ``` -/shuttle/points +/v0/shuttle/points ``` For shuttle arrivals: @@ -68,17 +68,12 @@ For shuttle stop estimates: #### Textbooks If the term is to be specified: ``` -/textbook//// -``` - -If the term is not to be specified: -``` -/textbook/// +/v0/textbook//// ``` #### News ``` -/news// +/v0/news// ``` From 4d1ec7a5d60602ec6d7daf053639335d8d852e61 Mon Sep 17 00:00:00 2001 From: Alex Date: Wed, 20 Dec 2017 00:38:27 -0500 Subject: [PATCH 7/7] Switched test over to using create_app --- tests/test_api.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/test_api.py b/tests/test_api.py index a38c80d..2c2107e 100644 --- a/tests/test_api.py +++ b/tests/test_api.py @@ -18,16 +18,16 @@ import unittest -from apiwrapper.v0.views import app +from apiwrapper import create_app class APITest(unittest.TestCase): def setUp(self): - self.app = app.test_client() + self.app = create_app().test_client() self.app.testing = True def test_lab_status_cath_g62(self): - result = self.app.get("/lab_status/cath_g62") + result = self.app.get("/v0/lab_status/cath_g62") self.assertEqual(result.status_code, 200) self.assertTrue("status" in result.get_data(True))