def testgeturl(self): expected = { '/URL:http://www.complete.org/%20/': 'http://www.complete.org/%20/', 'URL:telnet://foo.com/%20&foo=bar': 'telnet://foo.com/%20&foo=bar', '/foo' : 'gopher://MISSINGHOST:70/0/foo', '/About Me.txt' : 'gopher://MISSINGHOST:70/0/About%20Me.txt', '/' : 'gopher://MISSINGHOST:70/0/'} for selector, url in expected.items(): entry = GopherEntry(selector, self.config) entry.settype('0') self.assertEqual(url, entry.geturl()) self.assertEqual(re.sub('MISSINGHOST', 'NEWHOST', url), entry.geturl('NEWHOST')) self.assertEqual(re.sub('70', '10101', url), entry.geturl(defaultport = 10101)) entry.sethost('newhost') self.assertEqual(re.sub('MISSINGHOST', 'newhost', url), entry.geturl()) entry.setport(80) self.assertEqual(re.sub('MISSINGHOST:70', 'newhost:80', url), entry.geturl())
def testgeturl(self): expected = { "/URL:http://www.complete.org/%20/": "http://www.complete.org/%20/", "URL:telnet://foo.com/%20&foo=bar": "telnet://foo.com/%20&foo=bar", "/foo": "gopher://MISSINGHOST:70/0/foo", "/About Me.txt": "gopher://MISSINGHOST:70/0/About%20Me.txt", "/": "gopher://MISSINGHOST:70/0/", } for selector, url in list(expected.items()): entry = GopherEntry(selector, self.config) entry.settype("0") self.assertEqual(url, entry.geturl()) self.assertEqual(re.sub("MISSINGHOST", "NEWHOST", url), entry.geturl("NEWHOST")) self.assertEqual(re.sub("70", "10101", url), entry.geturl(defaultport=10101)) entry.sethost("newhost") self.assertEqual(re.sub("MISSINGHOST", "newhost", url), entry.geturl()) entry.setport(80) self.assertEqual(re.sub("MISSINGHOST:70", "newhost:80", url), entry.geturl())