Exemple #1
0
 def test_add_path(self):
     url = u'http://a.com'
     self.assertEquals('http://a.com/', ops.add_path(url, ''))
     self.assertEquals('http://a.com/path', ops.add_path(url, 'path'))
     self.assertEquals('http://a.com/path', ops.add_path(url, '/path'))
     self.assertEquals('http://a.com/path/', ops.add_path(url, 'path/'))
     self.assertEquals('http://a.com/path/', ops.add_path(url, '/path/'))
 def test_add_path(self):
     url = u'http://a.com'
     self.assertEquals('http://a.com/', ops.add_path(url, ''))
     self.assertEquals('http://a.com/path', ops.add_path(url, 'path'))
     self.assertEquals('http://a.com/path', ops.add_path(url, '/path'))
     self.assertEquals('http://a.com/path/', ops.add_path(url, 'path/'))
     self.assertEquals('http://a.com/path/', ops.add_path(url, '/path/'))
 def test_add_path_trailing_slash_and_existing_path(self):
     url = u'http://a.com/path1/'
     self.assertEquals('http://a.com/path1/path2',
                       ops.add_path(url, 'path2'))
     self.assertEquals('http://a.com/path1/path2',
                       ops.add_path(url, '/path2'))
     self.assertEquals('http://a.com/path1/path2/',
                       ops.add_path(url, 'path2/'))
     self.assertEquals('http://a.com/path1/path2/',
                       ops.add_path(url, '/path2/'))
Exemple #4
0
 def test_add_path_query_string(self):
     url = u'http://a.com/path1/?a=b'
     self.assertEquals('http://a.com/path1/path2?a=b', ops.add_path(url, 'path2'))
     self.assertEquals('http://a.com/path1/path2/?a=b', ops.add_path(url, 'path2/'))
Exemple #5
0
 def test_add_path_fragment(self):
     url = u'http://a.com/path1/#anchor'
     self.assertEquals('http://a.com/path1/path2#anchor', ops.add_path(url, 'path2'))
     self.assertEquals('http://a.com/path1/path2/#anchor', ops.add_path(url, 'path2/'))
Exemple #6
0
 def test_add_path_trailing_slash_and_existing_path(self):
     url = u'http://a.com/path1/'
     self.assertEquals('http://a.com/path1/path2', ops.add_path(url, 'path2'))
     self.assertEquals('http://a.com/path1/path2', ops.add_path(url, '/path2'))
     self.assertEquals('http://a.com/path1/path2/', ops.add_path(url, 'path2/'))
     self.assertEquals('http://a.com/path1/path2/', ops.add_path(url, '/path2/'))
 def test_add_path_query_string(self):
     url = u'http://a.com/path1/?a=b'
     self.assertEquals('http://a.com/path1/path2?a=b',
                       ops.add_path(url, 'path2'))
     self.assertEquals('http://a.com/path1/path2/?a=b',
                       ops.add_path(url, 'path2/'))
 def test_add_path_fragment(self):
     url = u'http://a.com/path1/#anchor'
     self.assertEquals('http://a.com/path1/path2#anchor',
                       ops.add_path(url, 'path2'))
     self.assertEquals('http://a.com/path1/path2/#anchor',
                       ops.add_path(url, 'path2/'))
Exemple #9
0
 def __getitem__(self, item):
     if isinstance(item, slice):
         params = {'offset': item.start,
                   'limit': item.stop - item.start}
         return self.copy(url=add_query_params(self.url, params))
     return self.copy(url=add_path(self.url, unicode(item)))
Exemple #10
0
 def __getitem__(self, item):
     if isinstance(item, slice):
         log.debug('Deprecated magic slice!')
         log.debug(traceback.format_stack())
         return self._range(item.start, item.stop)
     return self.copy(url=add_path(self.url, unicode(item)))
Exemple #11
0
 def __getitem__(self, item):
     if isinstance(item, slice):
         log.debug('Deprecated magic slice!')
         log.debug( traceback.format_stack())
         return self._range(item.start, item.stop)
     return self.copy(url=add_path(self.url, unicode(item)))