Exemplo n.º 1
0
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()))
Exemplo n.º 2
0
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))
Exemplo n.º 3
0
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()))
Exemplo n.º 4
0
def test_is_authenticated_returns_true_if_user_logged_in():
   auth.authenticated_user = '******'
   allowed = auth.is_authenticated()

   assert allowed == True
Exemplo n.º 5
0
def test_is_authenticated_returns_false_if_no_user_logged_in():
   auth.authenticated_user = None
   allowed = auth.is_authenticated()

   assert allowed == False