def get_mockdata_url(service_name, implementation_name,
                     url, headers):
    """
    :param service_name:
        possible "sws", "pws", "book", "hfs", etc.
    :param implementation_name:
        possible values: "file", etc.
    """

    RESOURCE_ROOT = _mockdata_path_root(service_name, implementation_name)
    file_path = None
    success = False
    start_time = time.time()

    mockdata_delay = getattr(settings, "RESTCLIENTS_MOCKDATA_DELAY", 0.0)
    time.sleep(mockdata_delay)

    for resource_dir in app_resource_dirs:
        logger.debug("Check url %s, service_name: %s, in resource_dir: %s" %
                     (url, service_name, resource_dir))

        response = _load_resource_from_path(resource_dir, service_name,
                                            implementation_name, url, headers)

        if response:
            request_time = time.time() - start_time
            rest_request.send(sender='restclients',
                              url=url,
                              request_time=request_time,
                              hostname=socket.gethostname(),
                              service_name=service_name)
            rest_request_passfail.send(sender='restclients',
                                       url=url,
                                       success=True,
                                       hostname=socket.gethostname(),
                                       service_name=service_name)
            return response

    # If no response has been found in any installed app, return a 404
    logger.info("404 for url %s, path: %s" %
                (url, "resources/%s/%s/%s" %
                 (service_name,
                  implementation_name,
                  convert_to_platform_safe(url))))
    rest_request_passfail.send(sender='restclients',
                               url=url,
                               success=False,
                               hostname=socket.gethostname(),
                               service_name=service_name)
    response = MockHTTP()
    response.status = 404
    response.reason = "Not Found"
    return response
def get_mockdata_url ( service_name , implementation_name , url , headers ) : RESOURCE_ROOT = _mockdata_path_root ( service_name , implementation_name ) file_path = None success = False start_time = time . time ( ) mockdata_delay = getattr ( settings , "RESTCLIENTS_MOCKDATA_DELAY" , 0.0 ) time . sleep ( mockdata_delay ) for resource_dir in app_resource_dirs : logger . debug ( "Check url %s, service_name: %s, in resource_dir: %s" % ( url , service_name , resource_dir ) ) response = _load_resource_from_path ( resource_dir , service_name , implementation_name , url , headers ) if response : request_time = time . time ( ) - start_time rest_request . send ( sender = 'restclients' , url = url , request_time = request_time , hostname = socket . gethostname ( ) , service_name = service_name ) rest_request_passfail . send ( sender = 'restclients' , url = url , success = True , hostname = socket . gethostname ( ) , service_name = service_name ) return response logger . info ( "404 for url %s, path: %s" % ( url , "resources/%s/%s/%s" % ( service_name , implementation_name , convert_to_platform_safe ( url ) ) ) ) rest_request_passfail . send ( sender = 'restclients' , url = url , success = False , hostname = socket . gethostname ( ) , service_name = service_name ) response = MockHTTP ( ) response . status = 404 response . reason = "Not Found" return response
:param service_name:
        possible "sws", "pws", "book", "hfs", etc.
    :param implementation_name:
        possible values: "file", etc.