# Path: openid/yadis/etxrd.py
# class XRDSError(Exception):
# class XRDSFraud(XRDSError):
# class _Max(object):
# def parseXRDS(text):
# def nsTag(ns, t):
# def mkXRDTag(t):
# def mkXRDSTag(t):
# def isXRDS(xrd_tree):
# def getYadisXRD(xrd_tree):
# def getXRDExpiration(xrd_element, default=None):
# def getCanonicalID(iname, xrd_tree):
#     def __eq__(self, other):
#     def __gt__(self, other):
# def getPriorityStrict(element):
# def getPriority(element):
# def prioSort(elements):
# def iterServices(xrd_tree):
# def sortedURIs(service_element):
# def getTypeURIs(service_element):
# def expandService(service_element):
# def expandServices(service_elements):
# XRD_NS_2_0 = 'xri://$xrd*($v*2.0)'
# XRDS_NS = 'xri://$xrds'
# 
# Path: openid/yadis/services.py
# def getServiceEndpoints(input_url, flt=None):
# def applyFilter(normalized_uri, xrd_data, flt=None):
# 
# Path: openid/yadis/xri.py
# XRI_AUTHORITIES = ['!', '=', '@', '+', '$', '(']
# def identifierScheme(identifier):
# def toIRINormal(xri):
# def _escape_xref(xref_match):
# def escapeForIRI(xri):
# def toURINormal(xri):
# def iriToURI(iri):
# def providerIsAuthoritative(providerID, canonicalID):
# def rootAuthority(xri):
# def XRI(xri):


import os.path
import tempfile
import unittest
import six
from lxml import etree
from openid.yadis import etxrd, services, xri
        """Make sure that we get an exception when an XRDS element is
        not present"""
        with open(NOXRDS_FILE, 'rb') as xml_file:
            self.xmldoc = xml_file.read()
        self.assertRaises(etxrd.XRDSError, services.applyFilter, self.yadis_url, self.xmldoc, None)

    def testEmpty(self):
        """Make sure that we get an exception when an XRDS element is
        not present"""
        self.xmldoc = ''
        self.assertRaises(etxrd.XRDSError, services.applyFilter, self.yadis_url, self.xmldoc, None)

    def testNoXRD(self):
        """Make sure that we get an exception when there is no XRD
        element present."""
        with open(NOXRD_FILE, 'rb') as xml_file:
            self.xmldoc = xml_file.read()
        self.assertRaises(etxrd.XRDSError, services.applyFilter, self.yadis_url, self.xmldoc, None)


class TestCanonicalID(unittest.TestCase):

    def mkTest(iname, filename, expectedID):
        """This function builds a method that runs the CanonicalID
        test for the given set of inputs"""

        filename = datapath(filename)

        def test(self):
            with open(filename, 'rb') as xrds_file:

# Path: openid/yadis/etxrd.py
# class XRDSError(Exception):
# class XRDSFraud(XRDSError):
# class _Max(object):
# def parseXRDS(text):
# def nsTag(ns, t):
# def mkXRDTag(t):
# def mkXRDSTag(t):
# def isXRDS(xrd_tree):
# def getYadisXRD(xrd_tree):
# def getXRDExpiration(xrd_element, default=None):
# def getCanonicalID(iname, xrd_tree):
#     def __eq__(self, other):
#     def __gt__(self, other):
# def getPriorityStrict(element):
# def getPriority(element):
# def prioSort(elements):
# def iterServices(xrd_tree):
# def sortedURIs(service_element):
# def getTypeURIs(service_element):
# def expandService(service_element):
# def expandServices(service_elements):
# XRD_NS_2_0 = 'xri://$xrd*($v*2.0)'
# XRDS_NS = 'xri://$xrds'
# 
# Path: openid/yadis/services.py
# def getServiceEndpoints(input_url, flt=None):
# def applyFilter(normalized_uri, xrd_data, flt=None):
# 
# Path: openid/yadis/xri.py
# XRI_AUTHORITIES = ['!', '=', '@', '+', '$', '(']
# def identifierScheme(identifier):
# def toIRINormal(xri):
# def _escape_xref(xref_match):
# def escapeForIRI(xri):
# def toURINormal(xri):
# def iriToURI(iri):
# def providerIsAuthoritative(providerID, canonicalID):
# def rootAuthority(xri):
# def XRI(xri):


# Path: openid/test/test_etxrd.py
import os.path
import tempfile
import unittest
import six
from lxml import etree
from openid.yadis import etxrd, services, xri

        """Make sure that we get an exception when an XRDS element is
        not present"""
        with open(NOXRDS_FILE, 'rb') as xml_file:
            self.xmldoc = xml_file.read()
        self.assertRaises(etxrd.XRDSError, services.applyFilter, self.yadis_url, self.xmldoc, None)

    def testEmpty(self):
        """Make sure that we get an exception when an XRDS element is
        not present"""
        self.xmldoc = ''
        self.assertRaises(etxrd.XRDSError, services.applyFilter, self.yadis_url, self.xmldoc, None)

    def testNoXRD(self):
        """Make sure that we get an exception when there is no XRD
        element present."""
        with open(NOXRD_FILE, 'rb') as xml_file:
            self.xmldoc = xml_file.read()
        self.assertRaises(etxrd.XRDSError, services.applyFilter, self.yadis_url, self.xmldoc, None)


class TestCanonicalID(unittest.TestCase):

    def mkTest(iname, filename, expectedID):
        """This function builds a method that runs the CanonicalID
        test for the given set of inputs"""

        filename = datapath(filename)

        def test(self):
            with open(filename, 'rb') as xrds_file:

                xrds = etxrd.parseXRDS(xrds_file.read())