# 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):


from unittest import TestCase
from openid.yadis import xri
    import unittest



class XriDiscoveryTestCase(TestCase):
    def test_isXRI(self):
        i = xri.identifierScheme
        self.assertEqual(i('=john.smith'), 'XRI')
        self.assertEqual(i('@smiths/john'), 'XRI')
        self.assertEqual(i('smoker.myopenid.com'), 'URI')
        self.assertEqual(i('xri://=john'), 'XRI')
        self.assertEqual(i(''), 'URI')


class XriEscapingTestCase(TestCase):
    def test_escaping_percents(self):
        self.assertEqual(xri.escapeForIRI('@example/abc%2Fd/ef'), '@example/abc%252Fd/ef')

    def test_escaping_xref(self):
        # no escapes
        esc = xri.escapeForIRI
        self.assertEqual('@example/foo/(@bar)', esc('@example/foo/(@bar)'))
        # escape slashes
        self.assertEqual('@example/foo/(@bar%2Fbaz)', esc('@example/foo/(@bar/baz)'))
        self.assertEqual('@example/foo/(@bar%2Fbaz)/(+a%2Fb)', esc('@example/foo/(@bar/baz)/(+a/b)'))
        # escape query ? and fragment #
        self.assertEqual('@example/foo/(@baz%3Fp=q%23r)?i=j#k', esc('@example/foo/(@baz?p=q#r)?i=j#k'))


class XriTransformationTestCase(TestCase):
    def test_to_iri_normal(self):

# 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_xri.py
from unittest import TestCase
from openid.yadis import xri
    import unittest




class XriDiscoveryTestCase(TestCase):
    def test_isXRI(self):
        i = xri.identifierScheme
        self.assertEqual(i('=john.smith'), 'XRI')
        self.assertEqual(i('@smiths/john'), 'XRI')
        self.assertEqual(i('smoker.myopenid.com'), 'URI')
        self.assertEqual(i('xri://=john'), 'XRI')
        self.assertEqual(i(''), 'URI')


class XriEscapingTestCase(TestCase):
    def test_escaping_percents(self):
        self.assertEqual(xri.escapeForIRI('@example/abc%2Fd/ef'), '@example/abc%252Fd/ef')

    def test_escaping_xref(self):
        # no escapes
        esc = xri.escapeForIRI
        self.assertEqual('@example/foo/(@bar)', esc('@example/foo/(@bar)'))
        # escape slashes
        self.assertEqual('@example/foo/(@bar%2Fbaz)', esc('@example/foo/(@bar/baz)'))
        self.assertEqual('@example/foo/(@bar%2Fbaz)/(+a%2Fb)', esc('@example/foo/(@bar/baz)/(+a/b)'))
        # escape query ? and fragment #
        self.assertEqual('@example/foo/(@baz%3Fp=q%23r)?i=j#k', esc('@example/foo/(@baz?p=q#r)?i=j#k'))


class XriTransformationTestCase(TestCase):
    def test_to_iri_normal(self):

        self.assertEqual(xri.toIRINormal('@example'), 'xri://@example')