Esempio n. 1
0
File: url.py Progetto: rsms/smisk
 def test_encode_decode_string_type(self):
   self.assertEquals(type(URL.encode(u"*****@*****.**")), type(u"*****@*****.**"))
   self.assertEquals(type(URL.encode("*****@*****.**")), type("*****@*****.**"))
   self.assertEquals(type(URL.escape(u"*****@*****.**")), type(u"*****@*****.**"))
   self.assertEquals(type(URL.escape("*****@*****.**")), type("*****@*****.**"))
   self.assertEquals(type(URL.decode(u"*****@*****.**")), type(u"*****@*****.**"))
   self.assertEquals(type(URL.decode("*****@*****.**")), type("*****@*****.**"))
Esempio n. 2
0
 def _call_leaf(self, args, params):
   '''
   Resolves and calls the appropriate leaf, passing args and params to it.
   
   :returns: Response structure or None
   :rtype:   dict
   '''
   # Add Content-Location response header if data encoding was deduced through
   # TCN or requested with a non-standard URI. (i.e. "/hello" instead of "/hello/")
   if self.response.serializer and not self.response.format:
     if self.destination.uri:
       path = URL.escape(self.request.cn_url.path) + '.' + self.response.serializer.extensions[0]
       self.response.headers.append('Content-Location: ' + \
         self.request.cn_url.to_s(scheme=0,user=0,host=0,port=0,path=path))
     # Always add the vary header, because we do (T)CN
     self.response.headers.append('Vary: Accept-Charset, Accept')
   else:
     # Always add the vary header, because we do (T)CN. Here we know this
     # request does not negotiate accept type, as response type was explicitly
     # set by the client, so we do not include "accept".
     self.response.headers.append('Vary: Accept-Charset')
   
   # Call leaf
   log.debug('calling destination %r with args %r and params %r', self.destination, args, params)
   if self._leaf_filter is not None:
     return self._leaf_filter(*args, **params)
   else:
     return self.destination(*args, **params)
Esempio n. 3
0
File: url.py Progetto: rsms/smisk
 def test_clean_strings(self):
   # Should be unmodified and retain pointers
   raw = 'hello/john'
   escaped = URL.escape(raw)
   self.assertEquals(escaped, raw)
   self.assertEquals(id(escaped), id(raw))
   
   raw = 'hello_john'
   encoded = URL.encode(raw)
   self.assertEquals(encoded, raw)
   self.assertEquals(id(encoded), id(raw))
Esempio n. 4
0
File: url.py Progetto: rsms/smisk
 def test_encode_decode(self):
   raw = "http://abc.se:12/mos/jäger/grek land/hej.html?mos=japp&öland=nej#ge-mig/då";
   escaped = URL.escape(raw)
   self.assertEquals(escaped,
     'http%3A//abc.se%3A12/mos/j%C3%A4ger/grek%20land/hej.html'\
     '?mos=japp&%C3%B6land=nej%23ge-mig/d%C3%A5')
   encoded = URL.encode(raw)
   self.assertEquals(encoded,
     'http%3A%2F%2Fabc.se%3A12%2Fmos%2Fj%C3%A4ger%2Fgrek%20land%2Fhej.html%3Fmos%3Djapp'\
     '%26%C3%B6land%3Dnej%23ge-mig%2Fd%C3%A5')
   self.assertEquals(URL.decode(escaped), raw)
   self.assertEquals(URL.decode(encoded), raw)
   self.assertEquals(URL.unescape(escaped), URL.decode(escaped))
   self.assertEquals(URL.decode("*****@*****.**"), "*****@*****.**")