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/'))
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/'))
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)))
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)))
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)))