Exemple #1
0
    def test_eq(self):
        iri1 = IRI(u'http://\N{CLOUD}/')
        iri2 = IRI(u'http://\N{CLOUD}/')
        self.assertEquals(iri1, iri2)

        uri1 = URI(iri1)
        uri2 = URI('http://xn--l3h/')
        self.assertEquals(uri1, uri2)

        self.assertNotEquals(iri1, uri1)
Exemple #2
0
 def test_iri_update_query(self):
     iri = IRI(u'http://\N{SNOWMAN}/')
     q = iri.query
     q.update({'foo': u'42'})
     iri2 = iri.update_query(q)
     self.assertNotEquals(iri, iri2)
     self.assertTrue(isinstance(iri2, IRI))
     self.assertEquals(repr(iri.query), "MultiDict([])")
     self.assertEquals(repr(iri2), "IRI(u'http://\u2603/?foo=42')")
     self.assertEquals(repr(iri2.query), "MultiDict([('foo', u'42')])")
Exemple #3
0
    def test_hashability(self):
        iri1 = IRI(u'http://\N{CLOUD}/')
        iri2 = IRI(u'http://\N{CLOUD}/')
        self.assertEquals(hash(iri1), hash(iri2))

        uri1 = URI(iri1)
        uri2 = URI('http://xn--l3h/')
        self.assertEquals(hash(uri1), hash(uri2))

        self.assertNotEquals(hash(iri1), hash(uri1))
Exemple #4
0
 def test_iri_update_query(self):
     iri = IRI(u'http://\N{SNOWMAN}/')
     q = iri.query
     q.update({'foo': u'42'})
     iri2 = iri.update_query(q)
     self.assertNotEquals(iri, iri2)
     self.assertTrue(isinstance(iri2, IRI))
     self.assertEquals(repr(iri.query), "MultiDict([])")
     self.assertEquals(repr(iri2), "IRI(u'http://\u2603/?foo=42')")
     self.assertEquals(repr(iri2.query), "MultiDict([('foo', u'42')])")
Exemple #5
0
    def test_ne(self):
        iri1 = IRI(u'http://\N{CLOUD}/')
        iri2 = IRI(u'http://\N{CLOUD}/')
        self.assertFalse(iri1 != iri2)

        uri1 = URI(iri1)
        uri2 = URI('http://xn--l3h/')
        self.assertFalse(uri1 != uri2)

        self.assertTrue(iri1 != uri1)
Exemple #6
0
 def test_convert_pile_of_poo(self):
     raise SkipTest("Not Implemented")
     iri = IRI(u"http://*****:*****@www.💩.la:80/path?q=arg#frag")
     try:
         URI(iri)
     except Exception as e:
         assert False, "{0} {1}".format(type(e), e)
Exemple #7
0
 def test_convert_pile_of_poo(self):
     raise SkipTest("Not Implemented")
     uri = URI("http://*****:*****@www.xn--ls8h.la:80/path?q=arg#frag".encode('utf-8'))
     try:
         IRI(uri)
     except Exception as e:
         assert False, "{0} {1}".format(type(e), e)
Exemple #8
0
class TestIRISnowman(cases.IdentifierCase):

    ri = IRI("http://*****:*****@www.\N{SNOWMAN}:80/path?q=arg#frag")
    expect = dict(
        scheme="http",
        auth="u:p",
        hostname="www.\u2603",
        port="80",
        path="/path",
        query=MultiDict([('q', 'arg')]),
        querystr='q=arg',
        fragment="frag",
        netloc="u:p@www.\u2603:80",
    )
Exemple #9
0
class TestIRIIPv6(cases.IdentifierCase):

    ri = IRI("http://*****:*****@[2a00:1450:4001:c01::67]:80/path?q=arg#frag")
    expect = dict(
        scheme="http",
        auth="u:p",
        hostname="2a00:1450:4001:c01::67",
        port="80",
        path="/path",
        query=MultiDict([('q', 'arg')]),
        querystr='q=arg',
        fragment="frag",
        netloc="u:p@[2a00:1450:4001:c01::67]:80",
    )
Exemple #10
0
class TestIRIPileOfPoo(cases.IdentifierCase):

    ri = IRI("http://*****:*****@www.💩.la:80/path?q=arg#frag")
    expect = dict(
        scheme="http",
        auth="u:p",
        hostname="www.💩.la",
        port="80",
        path="/path",
        query=MultiDict([('q', 'arg')]),
        querystr='q=arg',
        fragment="frag",
        netloc="u:p@www.💩.la:80",
    )
Exemple #11
0
class TestURIConvertedSnowman(cases.IdentifierCase):

    iri = IRI(u"http://*****:*****@www.\N{SNOWMAN}:80/path?q=arg#frag")
    ri = URI(iri)
    expect = dict(
        scheme="http",
        auth="u:p",
        hostname="www.xn--n3h",
        port="80",
        path="/path",
        query=MultiDict([('q', 'arg')]),
        querystr='q=arg',
        fragment="frag",
        netloc="u:[email protected]:80",
    )
Exemple #12
0
class TestIRIConvertedSnowman(cases.IdentifierCase):

    uri = URI(("http://*****:*****@www.%s:80/path?q=arg#frag"
               % u"\N{SNOWMAN}".encode('idna')).encode('utf-8'))
    ri = IRI(uri)
    expect = dict(
        scheme="http",
        auth="u:p",
        hostname="www.\u2603",
        port="80",
        path="/path",
        query=MultiDict([('q', 'arg')]),
        querystr='q=arg',
        fragment="frag",
        netloc="u:p@www.\u2603:80",
    )
Exemple #13
0
 def test_iri_add_port(self):
     iri = IRI(u'http://\N{SNOWMAN}/')
     new_iri = iri.update(port=8000)
     self.assertEquals(iri.netloc + ':8000', new_iri.netloc)
     self.assertEquals(new_iri.port, '8000')
     self.assertEquals(iri.port, None)
Exemple #14
0
def test_iri_template():
    eq_(IRI(u'http://\u2603/value'),
        IRI.from_template(u'http://\N{SNOWMAN}/{var}', var='value'))
    eq_(IRI(u'http://\u2603/'),
        IRI.from_template(u'http://{domain}/', domain=u"\N{SNOWMAN}"))
Exemple #15
0
 def test_iri_from_lenient(self):
     lenient_iri = IRI.from_lenient(u'http://de.wikipedia.org/wiki/Elf (Begriffskl\xe4rung)')
     self.assertEquals(repr(lenient_iri), "IRI(u'http://de.wikipedia.org/wiki/Elf%20%28Begriffskl%C3%A4rung%29')")
Exemple #16
0
 def test_cannot_join_uri(self):
     self.assertRaises(TypeError,
                       IRI('http://localhost:8000').join,
                       URI(str('/path/to/file'))
                      )
Exemple #17
0
 def test_uri_input(self):
     iri = TestIRISnowman.ri
     uri = URI(iri)
     self.assertEquals(str(iri), str(IRI(uri)))
     self.assertEquals(unicode(iri), unicode(IRI(uri)))
Exemple #18
0
 def test_idn_ascii_encoding(self):
     iri = IRI("http://Bücher.ch/")
     self.assertEquals(str(iri), "http://xn--bcher-kva.ch/")
Exemple #19
0
    def test_configurable_multi_dict_class(self):
        class CustomMultiDict(MultiDict):
            pass

        iri = IRI(u'http://\N{SNOWMAN}/', query_cls=CustomMultiDict)
        self.assertTrue(isinstance(iri.query, CustomMultiDict))
Exemple #20
0
 def test_iri_add_port(self):
     iri = IRI(u'http://\N{SNOWMAN}/')
     new_iri = iri.update(port=8000)
     self.assertEquals(iri.netloc + ':8000', new_iri.netloc)
     self.assertEquals(new_iri.port, '8000')
     self.assertEquals(iri.port, None)
Exemple #21
0
 def test_query_param_breaks_equality_(self):
     iri = IRI(u'http://\N{CLOUD}/')
     iri2 = IRI(u'http://\N{CLOUD}/?q=a')
     self.assertNotEquals(iri, iri2)
Exemple #22
0
 def test_non_existent_scheme(self):
     try:
         IRI("watwatwat://wat.wat/wat")
     except Exception as e:
         assert False, "{0} {1}".format(type(e), e)
Exemple #23
0
 def test_nonascii_query_keys(self):
     IRI(u'http://example.com/?gro\xdf=great')
Exemple #24
0
 def test_iri_from_lenient(self):
     lenient_iri = IRI.from_lenient(u'http://de.wikipedia.org/wiki/Elf (Begriffskl\xe4rung)')
     self.assertEquals(repr(lenient_iri), "IRI(u'http://de.wikipedia.org/wiki/Elf%20%28Begriffskl%C3%A4rung%29')")
Exemple #25
0
def test_iri_template():
    eq_(IRI(u'http://\u2603/value'),
        IRI.from_template(u'http://\N{SNOWMAN}/{var}', var='value'))
    eq_(IRI(u'http://\u2603/'),
        IRI.from_template(u'http://{domain}/', domain=u"\N{SNOWMAN}"))
Exemple #26
0
 def test_iri_input(self):
     uri = TestURISnowman.ri
     iri = IRI(uri)
     self.assertEquals(str(uri), str(URI(iri)))
     self.assertEquals(unicode(uri), unicode(URI(iri)))