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')
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')
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')
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')
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')
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", )
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", )
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", )
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", )
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", )
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", )
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')