def testMultiQueryParameters(self): http_url = "http://www.google.com:80/mail?locale=en_US&support=true#tab1" url = Url(http_url) parameters = url.get_query_parameters() self.assertTrue("locale" in parameters) self.assertEqual("en_US", parameters["locale"]) self.assertTrue("support" in parameters) self.assertEqual("true", parameters["support"])
def testUrl(self): http_url = "http://www.google.com:80/mail?locale=en_US#tab1" url = Url(http_url) self.assertEqual("http", url.protocol) self.assertEqual("www.google.com", url.hostname) self.assertEqual(80, url.port) self.assertEqual("tab1", url.hash) self.assertEqual("locale=en_US", url.query)
def testNoQueryParameters(self): http_url = "http://www.google.com:80/mail?missingValue#tab1" url = Url(http_url) parameters = url.get_query_parameters() self.assertTrue(len(parameters) == 0, parameters)
def testSingleQueryParameter(self): http_url = "http://www.google.com:80/mail?locale=en_US#tab1" url = Url(http_url) parameters = url.get_query_parameters() self.assertTrue("locale" in parameters) self.assertEqual("en_US", parameters["locale"])
def testInputOutput(self): http_url = "http://www.google.com:80/mail?locale=en_US#tab1" url = Url(http_url) self.assertEqual(http_url, str(url))