def runCustomTest(self): if self.expected is DiscoveryFailure: self.failUnlessRaises(DiscoveryFailure, discover, self.input_url) else: result = discover(self.input_url) self.failUnlessEqual(self.input_url, result.request_uri) msg = 'Identity URL mismatch: actual = %r, expected = %r' % ( result.normalized_uri, self.expected.normalized_uri) self.failUnlessEqual(self.expected.normalized_uri, result.normalized_uri, msg) msg = 'Content mismatch: actual = %r, expected = %r' % ( result.response_text, self.expected.response_text) self.failUnlessEqual(self.expected.response_text, result.response_text, msg) expected_keys = dir(self.expected) expected_keys.sort() actual_keys = dir(result) actual_keys.sort() self.failUnlessEqual(actual_keys, expected_keys) for k in dir(self.expected): if k.startswith('__') and k.endswith('__'): continue exp_v = getattr(self.expected, k) if isinstance(exp_v, types.MethodType): continue act_v = getattr(result, k) assert act_v == exp_v, (k, exp_v, act_v)
def runCustomTest(self): if self.expected is DiscoveryFailure: self.failUnlessRaises(DiscoveryFailure, discover, self.input_url) else: result = discover(self.input_url) self.failUnlessEqual(self.input_url, result.request_uri) msg = 'Identity URL mismatch: actual = %r, expected = %r' % ( result.normalized_uri, self.expected.normalized_uri) self.failUnlessEqual( self.expected.normalized_uri, result.normalized_uri, msg) msg = 'Content mismatch: actual = %r, expected = %r' % ( result.response_text, self.expected.response_text) self.failUnlessEqual( self.expected.response_text, result.response_text, msg) expected_keys = dir(self.expected) expected_keys.sort() actual_keys = dir(result) actual_keys.sort() self.failUnlessEqual(actual_keys, expected_keys) for k in dir(self.expected): if k.startswith('__') and k.endswith('__'): continue exp_v = getattr(self.expected, k) if isinstance(exp_v, types.MethodType): continue act_v = getattr(result, k) assert act_v == exp_v, (k, exp_v, act_v)
def getServiceEndpoints(input_url, flt=None): """Perform the Yadis protocol on the input URL and return an iterable of resulting endpoint objects. @param flt: A filter object or something that is convertable to a filter object (using mkFilter) that will be used to generate endpoint objects. This defaults to generating BasicEndpoint objects. @param input_url: The URL on which to perform the Yadis protocol @return: The normalized identity URL and an iterable of endpoint objects generated by the filter function. @rtype: (str, [endpoint]) @raises DiscoveryFailure: when Yadis fails to obtain an XRDS document. """ result = discover(input_url) try: endpoints = applyFilter(result.normalized_uri, result.response_text, flt) except XRDSError, err: raise DiscoveryFailure(str(err), None)