Пример #1
0
def test_not_found():
    tld_list = SUPPORTED_TLD[::]
    tld_list.remove('xn--p1ai')
    for tld in tld_list:
        domain1 = 'google.%s' % tld
        domain2 = 'sahchoo5theevaa8peel.%s' % tld
        with patch('whois2.get_whois', mock_get_whois):
            result1 = check(domain1)
            result2 = check(domain2)
        eq_(result1.registered, True, 'Domain %s is identified as unregistered while it is' % domain1)
        eq_(result2.registered, False, 'Domain %s is identified as registered while it is not' % domain2)
Пример #2
0
def test_nameservers():
    tld_list = SUPPORTED_TLD[::]
    tld_list.remove('xn--p1ai')
    tld_list.remove('name')

    default_nameservers = set(['ns1.google.com', 'ns2.google.com', 'ns3.google.com', 'ns4.google.com'])
    nameservers = {
        'aero': set([]),
        'sc': set(['ns1.google.com', 'ns2.google.com']),
        'pro': set(['ns1.google.com', 'ns2.google.com']),
        'hn': set(['ns1.google.com', 'ns2.google.com']),
        'tv': set(['ns1.google.com', 'ns2.google.com', 'ns3.google.com']),
        'msk.ru': set(['ns1.nic.com.ru', 'ns2.nic.com.ru']),
        'net.ru': set(['ns1.masterhost.ru', 'ns2.masterhost.ru', 'ns.masterhost.ru']),
        'org.ru': set(['ns1.parked.ru', 'ns2.parked.ru']),
        'pp.ru': set(['ns1.hostline.ru', 'ns2.hostline.ru']),
        'spb.ru': set(['ns.runnet.ru', 'ns2.runnet.ru']),
        'su': set(['ns1073.hostgator.com', 'ns1074.hostgator.com']),
        'tel': set(['a0.cth.dns.nic.tel', 'd0.cth.dns.nic.tel', 'n0.cth.dns.nic.tel', 's0.cth.dns.nic.tel', 't0.cth.dns.nic.tel']),
    }

    for tld in tld_list:
        domain = 'google.%s' % tld
        with patch('whois2.get_whois', mock_get_whois):
            result = check(domain)
        ok_(hasattr(result, 'nameservers'), 'List of {0} nameservers is undefined'.format(domain))
        expected_nameservers = nameservers.get(tld, default_nameservers)
        eq_(set(result.nameservers), expected_nameservers,
            'List of {0} nameservers is {1}, not {2}'.format(domain, result.nameservers, expected_nameservers)
        )
Пример #3
0
def test_ru_dates():
    domain = 'google.ru'
    with patch('whois2.get_whois', mock_get_whois):
        result = check(domain)
    ok_(result.created, datetime.datetime(2004, 7, 21))
    ok_(result.paid_till, datetime.datetime(2013, 3, 5))