diff --git a/test_miniuri.py b/test_miniuri.py index 141e466..2c9b0b6 100644 --- a/test_miniuri.py +++ b/test_miniuri.py @@ -17,7 +17,7 @@ class TestMiniUri(TestCase): def test_authority(self): self.assertEqual(self.u.authority, 'fox:pass@www.foxhop.net:81') - def test_authority(self): + def test_userinfo(self): self.assertEqual(self.u.userinfo, 'fox:pass') def test_username(self): @@ -47,3 +47,79 @@ class TestMiniUri(TestCase): def test_fragment(self): self.assertEqual(self.u.fragment, '5') + # test_change_ + # https://fox:pass@www.foxhop.net:81/path/filename.jpg?p=2#5 + + def test_change_uri(self): + self.u.uri = 'http://zell:sapp@wwws.foxhop.net:82/my/file.png?p=3#6' + self.assertEqual(self.u.uri, 'http://zell:sapp@wwws.foxhop.net:82/my/file.png?p=3#6') + + def test_change_scheme(self): + self.u.scheme = 'http' + self.assertEqual(self.u.scheme, 'http') + self.assertEqual(self.u.uri, 'http://fox:pass@www.foxhop.net:81/path/filename.jpg?p=2#5') + + def test_change_authority(self): + self.u.authority = 'zell:ssap@wwws.foxhop.net:82' + self.assertEqual(self.u.authority, 'zell:ssap@wwws.foxhop.net:82') + self.assertEqual(self.u.uri, 'https://zell:ssap@wwws.foxhop.net:82/path/filename.jpg?p=2#5') + + def test_change_userinfo(self): + self.u.userinfo = 'zell:ssap' + self.assertEqual(self.u.userinfo, 'zell:ssap') + self.assertEqual(self.u.uri, 'https://zell:ssap@www.foxhop.net:81/path/filename.jpg?p=2#5') + self.u.userinfo = 'zell' + self.assertEqual(self.u.userinfo, 'zell') + self.assertEqual(self.u.uri, 'https://zell@www.foxhop.net:81/path/filename.jpg?p=2#5') + + def test_change_username(self): + self.u.username = 'zell' + self.assertEqual(self.u.username, 'zell') + self.assertEqual(self.u.uri, 'https://zell:pass@www.foxhop.net:81/path/filename.jpg?p=2#5') + + def test_change_password(self): + self.u.password = 'ssap' + self.assertEqual(self.u.password, 'ssap') + self.assertEqual(self.u.uri, 'https://fox:ssap@www.foxhop.net:81/path/filename.jpg?p=2#5') + + def test_change_hostname(self): + self.u.hostname = 'wwws.foxhop.net' + self.assertEqual(self.u.hostname, 'wwws.foxhop.net') + self.assertEqual(self.u.uri, 'https://fox:pass@wwws.foxhop.net:81/path/filename.jpg?p=2#5') + + def test_change_port(self): + self.u.port = '82' + self.assertEqual(self.u.port, '82') + self.assertEqual(self.u.uri, 'https://fox:pass@www.foxhop.net:82/path/filename.jpg?p=2#5') + + def test_change_path(self): + # TODO: filename and extension not updated + self.u.path = '/my/file.png' + self.assertEqual(self.u.path, '/my/file.png') + self.assertEqual(self.u.filename, 'file.png') + self.assertEqual(self.u.extension, 'png') + self.assertEqual(self.u.uri, 'https://fox:pass@www.foxhop.net:82/my/file.png?p=2#5') + + def test_change_filename(self): + self.u.filename = 'file.png' + self.assertEqual(self.u.filename, 'file.png') + self.assertEqual(self.u.uri, 'https://fox:pass@www.foxhop.net:81/path/file.png?p=2#5') + + def test_change_extension(self): + # TODO: attribute error + self.u.extension = 'png' + self.assertEqual(self.u.extension, 'png') + self.assertEqual(self.u.filename, 'filename.png') + self.assertEqual(self.u.uri, 'https://fox:pass@www.foxhop.net:81/path/filename.png?p=2#5') + + def test_change_query(self): + self.u.query = 'p=3' + self.assertEqual(self.u.query, 'p=3') + self.assertEqual(self.u.uri, 'https://fox:pass@www.foxhop.net:81/path/filename.jpg?p=3#5') + + def test_change_fragment(self): + self.u.fragment = '6' + self.assertEqual(self.u.fragment, '6') + self.assertEqual(self.u.uri, 'https://fox:pass@www.foxhop.net:81/path/filename.jpg?p=2#6') + +