'Test GenericConsumer.complete()\'s handling of good
return_to values.'

def test_completeGoodReturnTo(self):

    return_to = 'http://some.url/path'
    good_return_tos = [(return_to, {}), ((return_to + '?another=arg'), {(BARE_NS, 'another'): 'arg'}), ((return_to + '?another=arg#fragment'), {(BARE_NS, 'another'): 'arg'}), (('HTTP' + return_to[4:]), {}), (return_to.replace('url', 'URL'), {}), ('http://some.url:80/path', {}), ('http://some.url/p%61th', {}), ('http://some.url/./path', {})]
    endpoint = None
    for (good, extra) in good_return_tos:
        m = Message(OPENID1_NS)
        m.setArg(OPENID_NS, 'mode', 'cancel')
        for (ns, key) in extra:
            m.setArg(ns, key, extra[(ns, key)])
        m.setArg(OPENID_NS, 'return_to', good)
        result = self.consumer.complete(m, endpoint, return_to)
        self.failUnless(isinstance(result, CancelResponse), ('Expected    CancelResponse,    got    %r    for    %s' % (result, good)))
