def test_url_param_strip(self): u = 'http://test.com/?foo=bar&abc=def&z=1' # Non existent parameter self.assertEqual(url_strip_query_param(u, 'xxx'), u) # Try some variations self.assertEqual(url_strip_query_param(u, 'foo'), 'http://test.com/?abc=def&z=1') self.assertEqual(url_strip_query_param(u, 'abc'), 'http://test.com/?foo=bar&z=1') self.assertEqual(url_strip_query_param(u, 'z'), 'http://test.com/?foo=bar&abc=def') # Check corner cases u = 'http://test.com/?' self.assertEqual(url_strip_query_param(u, 'xxx'), u)
def get_next_url(self, url): """ Generates URLs for the current website """ npage = int(url_get_query_param(url, 'page', '0')) url = url_strip_query_param(url, 'page') if url.find('?') == -1: url += '?' return "{0}&page={1}".format(url, npage + 1)