예제 #1
0
def generateResult(base_url, input_name, id_name, result_name, success):
    input_url = urlparse.urljoin(base_url, input_name)

    # If the name is None then we expect the protocol to fail, which
    # we represent by None
    if id_name is None:
        assert result_name is None
        return input_url, DiscoveryFailure

    result = generateSample(result_name, base_url)
    headers, content = result.split('\n\n', 1)
    header_lines = headers.split('\n')
    for header_line in header_lines:
        if header_line.startswith('Content-Type:'):
            _, ctype = header_line.split(':', 1)
            ctype = ctype.strip()
            break
    else:
        ctype = None

    id_url = urlparse.urljoin(base_url, id_name)

    result = DiscoveryResult(input_url)
    result.normalized_uri = id_url
    if success:
        result.xrds_uri = urlparse.urljoin(base_url, result_name)
    result.content_type = ctype
    result.response_text = content
    return input_url, result
예제 #2
0
def generateResult(base_url, input_name, id_name, result_name, success):
    input_url = urlparse.urljoin(base_url, input_name)

    # If the name is None then we expect the protocol to fail, which
    # we represent by None
    if id_name is None:
        assert result_name is None
        return input_url, DiscoveryFailure

    result = generateSample(result_name, base_url)
    headers, content = result.split('\n\n', 1)
    header_lines = headers.split('\n')
    for header_line in header_lines:
        if header_line.startswith('Content-Type:'):
            _, ctype = header_line.split(':', 1)
            ctype = ctype.strip()
            break
    else:
        ctype = None

    id_url = urlparse.urljoin(base_url, id_name)

    result = DiscoveryResult(input_url)
    result.normalized_uri = id_url
    if success:
        result.xrds_uri = urlparse.urljoin(base_url, result_name)
    result.content_type = ctype
    result.response_text = content
    return input_url, result
예제 #3
0
 def discover(self, input_url):
     result = DiscoveryResult(input_url)
     result.response_text = "This is not XRDS text."
     return result
예제 #4
0
 def discover(self, input_url):
     result = DiscoveryResult(input_url)
     result.response_text = "This is not XRDS text."
     return result
예제 #5
0
 def mockDiscover(self, uri):
     result = DiscoveryResult(uri)
     result.response_text = self.data
     result.normalized_uri = uri
     return result
예제 #6
0
 def mockDiscover(self, uri):
     result = DiscoveryResult(uri)
     result.response_text = self.data
     result.normalized_uri = uri
     return result