o ^@s\dZeZdgZddlmZddlZddlmZm Z m Z m Z m Z Gdddej Zdd ZdS) z Unit tests. test_suite) defaultdictN)InvalidURIErrorURIfind_uris_in_textmergeremove_dot_segmentsc@sTeZdZddZddZddZddZd d Zd d Zd dZ ddZ ddZ dS) URITestCasecCs||ttdd|ttdd|ttdd|ttdd|ttd d|ttd ddS) N"eXAMPLE://a/./b/../b/%63/%7bfoo%7dexample://a/b/c/%7Bfoo%7Dhttp://www.EXAMPLE.com/http://www.example.com/http://www.gnome.org/%7ejamesh/http://www.gnome.org/~jamesh/http://example.comhttp://example.com/http://example.com:/http://example.com:80/) assertEqualstrrselfr9/usr/lib/python3/dist-packages/lazr/uri/tests/test_uri.pytest_normalisation!s$zURITestCase.test_normalisationc Csddgddgddggdg}tt}|D]}|D] }|tt||qq|t|t||D]}|t|t|tt|dq3dS) Nr r r r rr)rrrrr)rlisthashrappendrlensorted)r uri_groups uri_hashes uri_groupurirrr test_hashable4s. zURITestCase.test_hashablecCs|ttddS)Nuhttp://€xample.com/) assertRaisesrrrrrrtest_invalid_uriKszURITestCase.test_invalid_uricCs\|tddddd|tddddd|tddddd|td dddddS) NfooT) has_authorityz/fooFz/a/b/cz/a/b/fooz/a/b/)rrrrrr test_mergeNszURITestCase.test_mergecCs$|tdd|tdddS)Nz/a/b/c/./../../gz/a/gzmid/content=5/../6zmid/6)rrrrrrtest_remove_dot_segmentsXsz$URITestCase.test_remove_dot_segmentscstdfdd}||dd||dd||dd||dd ||d d ||d d ||dd||dd||dd||dd||dd||dd||dd||dd||dd||dd ||d!d ||d"d#||d$d#||d%d&||d'd(||d)d(||d*d dS)+Nhttp://a/b/c/d;p?qct|SNrresolverelativebaserrr0`z3URITestCase.test_normal_resolution..resolvezg:hgzhttp://a/b/c/gz./gzg/http://a/b/c/g/z/g http://a/gz//gz http://g/z?yzhttp://a/b/c/d;p?yzg?yzhttp://a/b/c/g?yz#szhttp://a/b/c/d;p?q#szg#szhttp://a/b/c/g#szg?y#szhttp://a/b/c/g?y#sz;xzhttp://a/b/c/;xzg;xzhttp://a/b/c/g;xzg;x?y#szhttp://a/b/c/g;x?y#sr'.z http://a/b/c/z./z..z http://a/b/z../z../g http://a/b/gz../..z http://a/z../../z../../grrrr0rr3rtest_normal_resolution]s2 z"URITestCase.test_normal_resolutioncs8tdfdd}||dd||dd||dd||dd||d d ||d d ||d d||dd||dd||dd||dd||dd||dd||dd||dd||dd ||d!d"||d#d$dS)%Nr,cr-r.r/r1r3rrr0~r5z5URITestCase.test_abnormal_resolution..resolvez ../../../gr8z ../../../../gz/./gz/../gzg.zhttp://a/b/c/g.z.gzhttp://a/b/c/.gzg..zhttp://a/b/c/g..z..gzhttp://a/b/c/..gz./../gr:z./g/.r7zg/./hzhttp://a/b/c/g/hzg/../hzhttp://a/b/c/hz g;x=1/./yzhttp://a/b/c/g;x=1/yz g;x=1/../yzhttp://a/b/c/yzg?y/./xzhttp://a/b/c/g?y/./xzg?y/../xzhttp://a/b/c/g?y/../xzg#s/./xzhttp://a/b/c/g#s/./xzg#s/../xzhttp://a/b/c/g#s/../xr;r<rr3rtest_abnormal_resolution{s( z$URITestCase.test_abnormal_resolutioncC<td}||d||d||ddS)Nhttp://code.launchpad.dev/foozcode.launchpad.devz launchpad.devr')r assertTrue underDomainrr#rrr"test_underDomain_matches_subdomainz.URITestCase.test_underDomain_matches_subdomaincCr?)Nr@zbeta.code.launchpad.devz google.comz unchpad.dev)r assertFalserBrCrrr+test_underDomain_doesnt_match_non_subdomainrEz7URITestCase.test_underDomain_doesnt_match_non_subdomainN) __name__ __module__ __qualname__rr$r&r*r+r=r>rDrGrrrrr s  r cCsttSr.)unittest TestLoaderloadTestsFromNamerHrrrradditional_testsr5rN)__doc__type __metaclass____all__ collectionsrrKlazr.urirrrrrTestCaser rNrrrrs