Skip to content

Commit

Permalink
Add status endpoint (#117)
Browse files Browse the repository at this point in the history
  • Loading branch information
nathanfranklin authored Jan 23, 2023
1 parent db37557 commit d36632f
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 0 deletions.
2 changes: 2 additions & 0 deletions geoapi/routes/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from flask_restx import Api
from .projects import api as projects
from .status import api as status
from .streetview import api as streetview
from .notifications import api as notifications
from .public_projects import api as public_projects
Expand All @@ -26,4 +27,5 @@
api.add_namespace(projects)
api.add_namespace(public_projects)
api.add_namespace(notifications)
api.add_namespace(status)
api.add_namespace(streetview)
23 changes: 23 additions & 0 deletions geoapi/routes/status.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
from flask_restx import Resource, Namespace, fields
import time
from geoapi.log import logging
from geoapi.utils.decorators import jwt_decoder, not_anonymous

logger = logging.getLogger(__name__)

api = Namespace('status', decorators=[jwt_decoder])

status_response = api.model('StatusResponse', {
"status": fields.String(),
})


@api.route("/")
class Status(Resource):
@api.doc(id="get",
description='Get status')
@api.marshal_with(status_response)
@not_anonymous
def get(self):
time.sleep(1)
return {"status": "OK"}
11 changes: 11 additions & 0 deletions geoapi/tests/api_tests/test_status_routes.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
def test_get_status_unauthorized_guest(test_client, projects_fixture):
resp = test_client.get('/status/')
assert resp.status_code == 403


def test_get_status(test_client, user1):
resp = test_client.get('/status/',
headers={'x-jwt-assertion-test': user1.jwt})
data = resp.get_json()
assert resp.status_code == 200
assert data == {'status': 'OK'}

0 comments on commit d36632f

Please sign in to comment.