-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
db37557
commit d36632f
Showing
3 changed files
with
36 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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'} |