def quote(): """Gets a quote for user based on pricing module calculations Supported methods: POST Returns: HTTP success otherwise HTTP 401 or 405 On successful POST returns quote results as json in response. """ if not authentication.is_authenticated(): return error_handler(401) user = authentication.get_authenticated_user() return success_handler(quotes.get_quote(user, request.get_json()))
def quote_history(): """Returns quote history for logged in user Supported methods: GET Returns: HTTP success otherwise HTTP 401 or 405 On successful GET returns """ if not authentication.is_authenticated(): return error_handler(401) if request.method == 'GET': user = authentication.get_authenticated_user() return success_handler(quotes.get_quote_history(user))
def profile(): """Gets or Sets users profile data. Supported methods: GET POST Returns: HTTP sucess on successful GET or POST HTTP 401 if user is not logged in HTTP 405 otherwise On successful GET or POST returns json with current profile data """ if not authentication.is_authenticated(): return error_handler(401) if request.method == 'POST': return success_handler( profile_management.update_profile( authentication.get_authenticated_user(), request.get_json())) if request.method == 'GET': return success_handler( profile_management.get_profile( authentication.get_authenticated_user()))
def test_is_authenticated_returns_true_if_user_logged_in(): auth.authenticated_user = '******' allowed = auth.is_authenticated() assert allowed == True
def test_is_authenticated_returns_false_if_no_user_logged_in(): auth.authenticated_user = None allowed = auth.is_authenticated() assert allowed == False