test_host.py (974B)
1 # standard imports 2 import unittest 3 4 # local imports 5 from urlybird.host import url_apply_port_string 6 7 8 class TestHost(unittest.TestCase): 9 10 def test_host_strings(self): 11 s = 'http://localhost' 12 v = 'http://localhost:80' 13 r = url_apply_port_string(s) 14 self.assertEqual(r, v) 15 16 s = 'http://localhost:80' 17 v = 'http://localhost:80' 18 r = url_apply_port_string(s) 19 self.assertEqual(r, v) 20 21 s = 'http://localhost:8000' 22 v = 'http://localhost:8000' 23 r = url_apply_port_string(s) 24 self.assertEqual(r, v) 25 26 s = 'https://localhost/foo/bar?baz=xyzzy' 27 v = 'https://localhost:443/foo/bar?baz=xyzzy' 28 r = url_apply_port_string(s) 29 self.assertEqual(r, v) 30 31 s = 'https://localhost/foo/bar?baz=xyzzy' 32 v = 'https://localhost:443' 33 r = url_apply_port_string(s, as_origin=True) 34 self.assertEqual(r, v) 35 36 if __name__ == '__main__': 37 unittest.main()