Ejemplo n.º 1
0
 def test_update_query_with_nonascii_query_object(self):
     ri = self.RI('http://localhost:8000/path/to/file?yes=no')
     ri = ri.update_query(MultiDict({'häus': 'höf'}))
     self.assertEquals(ri.path, '/path/to/file')
     self.assertEquals(
         ri.query,
         MultiDict([('häus'.encode('utf-8'), 'höf'), ('yes', 'no')]))
     self.assertEquals(ri.querystr, 'yes=no&h%C3%A4us=h%C3%B6f')
Ejemplo n.º 2
0
 def test_update_query_with_query_object_to_make_multi_query(self):
     ri = self.RI('http://localhost:8000/path/to/file?yes=no')
     ri = ri.update_query(MultiDict(dict(yes='maybe', left='right')))
     self.assertEquals(ri.path, '/path/to/file')
     self.assertEquals(
         ri.query,
         MultiDict([('yes', 'no'), ('yes', 'maybe'), ('left', 'right')]))
     self.assertEquals(ri.querystr, 'yes=no&yes=maybe&left=right')
Ejemplo n.º 3
0
 def test_join_fragment_to_query(self):
     ri = self.RI('http://rubberchick.en/path/to/file?yes=no').join(
         self.RI('#giblets'))
     self.assertEquals(ri.path, '/path/to/file')
     self.assertEquals(ri.query, MultiDict(dict(yes='no', )))
     self.assertEquals(ri.querystr, 'yes=no')
     self.assertEquals(ri.fragment, 'giblets')
Ejemplo n.º 4
0
 def test_join_nonascii_query_to_query(self):
     ri = self.RI('http://localhost:8000/path/to/file?yes=no').join(
         self.RI('?h%C3%A4us=h%C3%B6f'))
     self.assertEquals(ri.path, '/path/to/file')
     self.assertEquals(
         ri.query,
         MultiDict([('häus'.encode('utf-8'), 'höf'), ('yes', 'no')]))
     self.assertEquals(ri.querystr, 'h%C3%A4us=h%C3%B6f&yes=no')
Ejemplo n.º 5
0
 def test_join_query_to_query_to_make_multi_query(self):
     ri = self.RI('http://localhost:8000/path/to/file?yes=no').join(
         self.RI('?yes=maybe&left=right'))
     self.assertEquals(ri.path, '/path/to/file')
     self.assertEquals(
         ri.query,
         MultiDict([('yes', 'no'), ('yes', 'maybe'), ('left', 'right')]))
     self.assertEquals(ri.querystr, 'yes=no&yes=maybe&left=right')
Ejemplo n.º 6
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",
    )
Ejemplo n.º 7
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",
    )
Ejemplo n.º 8
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",
    )
Ejemplo n.º 9
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",
    )
Ejemplo n.º 10
0
class TestURISnowman(cases.IdentifierCase):

    ri = URI("http://*****:*****@www.%s:80/path?q=arg#frag" %
             u"\N{SNOWMAN}".encode('idna'))
    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",
    )
Ejemplo n.º 11
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",
    )
Ejemplo n.º 12
0
 def test_join_query_to_query(self):
     ri = self.RI('http://localhost:8000/path/to/file?yes=no').join(
         self.RI('?left=right'))
     self.assertEquals(ri.path, '/path/to/file')
     self.assertEquals(ri.query, MultiDict(dict(yes='no', left='right')))
     self.assertEquals(ri.querystr, 'yes=no&left=right')