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
def discover(self, input_url): result = DiscoveryResult(input_url) result.response_text = "This is not XRDS text." return result
def mockDiscover(self, uri): result = DiscoveryResult(uri) result.response_text = self.data result.normalized_uri = uri return result