# -*- coding: utf-8 -*-1# This program is free software; you can redistribute it and/or modify2# it under the terms of the GNU General Public License as published by3# the Free Software Foundation; either version 2 of the License, or4# (at your option) any later version.5#6# This program is distributed in the hope that it will be useful,7# but WITHOUT ANY WARRANTY; without even the implied warranty of8# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the9# GNU General Public License for more details.10#11# You should have received a copy of the GNU General Public License12# along with this program; if not, write to the Free Software13# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,14# MA 02110-1301, USA.15#16# Author: Mauro Soria1718from unittest import TestCase1920from lib.core.settings import DUMMY_URL21from lib.parse.url import clean_path, parse_path222324class TestURLParsers(TestCase):25def test_clean_path(self):26self.assertEqual(clean_path("/foo?a=1#a=1"), "/foo")27self.assertEqual(clean_path("/foo?a=1#a=1", keep_queries=True), "/foo?a=1")2829def test_parse_path(self):30self.assertEqual(31parse_path("foo/bar"),32"foo/bar",33"Path parser gives unexpected result")34self.assertEqual(35parse_path("/foo/bar"),36"foo/bar",37"Path parser gives unexpected result")38self.assertEqual(39parse_path(f"{DUMMY_URL}foo/bar"),40"foo/bar",41"Path parser gives unexpected result",42)434445