Exemple #1
0
 def testIPaddr(self):
     assert tasprefix.prefix("http://127.2.34.56/foo") == "127.2.34.56"
     # IP V6
     assert (
         tasprefix.prefix("http://[2001:0db8:85a3:08d3:1319:8a2e:0370:7344]/")
         == "[2001:0db8:85a3:08d3:1319:8a2e:0370:7344]"
     )
Exemple #2
0
def testBasic():
    assert tasprefix.prefix('http://www.archive.org') == 'org,archive,'
    assert tasprefix.prefix('http://www.archive.org/movies') == \
        'org,archive,'
    assert tasprefix.prefix('http://www.archive.org:8080/') == \
        'org,archive,'
    assert tasprefix.prefix('http://*****:*****@www.archive.org/movies/') \
        == 'org,archive,'
Exemple #3
0
    def testMoreDomains(self):
        assert tasprefix.prefix("http://www.example.com/") == "com,example,"
        assert tasprefix.prefix("http://example.com/") == "com,example,"
        assert tasprefix.prefix("http://www.yahoo.fr/") == "fr,yahoo,"
        assert tasprefix.prefix("http://www.foobar.com.au/") == "au,com,foobar,"
        assert tasprefix.prefix("http://www.virgin.co.uk/") == "uk,co,virgin,"
        assert tasprefix.prefix("http://www.assigned.public.tokyo.jp") == "jp,tokyo,public,assigned,"

        assert tasprefix.prefix("http://www.bad-site.de") == "de,bad-site,"
        assert tasprefix.prefix("http://www.archive4u.de") == "de,archive4u,"
Exemple #4
0
def testMoreDomains():
    assert tasprefix.prefix('http://www.example.com/') == 'com,example,'
    assert tasprefix.prefix('http://example.com/') == 'com,example,'
    assert tasprefix.prefix('http://www.yahoo.fr/') == 'fr,yahoo,'
    assert tasprefix.prefix('http://www.foobar.com.au/') == 'au,com,foobar,'
    assert tasprefix.prefix('http://www.virgin.co.uk/') == 'uk,co,virgin,'
    assert tasprefix.prefix('http://www.assigned.public.tokyo.jp') == \
        'jp,tokyo,public,assigned,'

    assert tasprefix.prefix('http://www.bad-site.de') == 'de,bad-site,'
    assert tasprefix.prefix('http://www.archive4u.de') == 'de,archive4u,'
Exemple #5
0
 def testBasic(self):
     assert tasprefix.prefix("http://www.archive.org") == "org,archive,"
     assert tasprefix.prefix("http://www.archive.org/movies") == "org,archive,"
     assert tasprefix.prefix("http://www.archive.org:8080/") == "org,archive,"
     assert tasprefix.prefix("http://*****:*****@www.archive.org/movies/") == "org,archive,"
Exemple #6
0
 def testUnknownTLD(self):
     assert tasprefix.prefix("http://www.example.zzz") == "zzz,example,"
Exemple #7
0
 def testExceptionRules(self):
     assert tasprefix.prefix("http://www.bl.uk") == "uk,bl,"
     assert tasprefix.prefix("http://subdomain.metro.tokyo.jp") == "jp,tokyo,metro,"
     assert tasprefix.prefix("http://metro.tokyo.jp") == "jp,tokyo,metro,"
Exemple #8
0
def testUnknownTLD():
    assert tasprefix.prefix('http://www.example.zzz') == 'zzz,example,'
Exemple #9
0
def testExceptionRules():
    assert tasprefix.prefix('http://www.bl.uk') == 'uk,bl,'
    assert tasprefix.prefix('http://subdomain.metro.tokyo.jp') == \
        'jp,tokyo,metro,'
    assert tasprefix.prefix('http://metro.tokyo.jp') == 'jp,tokyo,metro,'
Exemple #10
0
def testIPaddr():
    assert tasprefix.prefix('http://127.2.34.56/foo') == \
        '127.2.34.56'
    # IP V6
    assert tasprefix.prefix('http://[2001:0db8:85a3:08d3:1319:8a2e:0370:7344]/') \
        == '[2001:0db8:85a3:08d3:1319:8a2e:0370:7344]'
Exemple #11
0
 def hosthash(self, curi):
     prefix = tasprefix.prefix(curi)
     if isinstance(prefix, unicode):
         prefix = prefix.encode('utf-8')
     return int(self._fp31.fp(prefix))