Commit 57cd341b by William Tisäter

Add test for ISP database

parent e52a6df3
......@@ -7,3 +7,4 @@ REGION_DB_PATH = path.join(DATA_DIR, 'GeoIPRegion.dat')
CITY_DB_PATH = path.join(DATA_DIR, 'GeoLiteCity.dat')
ORG_DB_PATH = path.join(DATA_DIR, 'GeoIPOrg.dat')
ASNUM_DB_PATH = path.join(DATA_DIR, 'GeoIPASNum.dat')
ISP_DB_PATH = path.join(DATA_DIR, 'GeoIPISP.dat')
......@@ -94,20 +94,6 @@ class TestGeoIPCityFunctions(unittest.TestCase):
self.assertEqual(us_region, self.us_region_data)
self.assertEqual(gb_region, self.gb_region_data)
def testTimeZoneByAddr(self):
us_time_zone = self.gic.time_zone_by_addr(self.us_ip)
gb_time_zone = self.gic.time_zone_by_addr(self.gb_ip)
self.assertEquals(us_time_zone, 'America/Los_Angeles')
self.assertEquals(gb_time_zone, 'Europe/London')
def testTimeZoneByName(self):
us_time_zone = self.gic.time_zone_by_name(self.us_hostname)
gb_time_zone = self.gic.time_zone_by_name(self.gb_hostname)
self.assertEquals(us_time_zone, 'America/Los_Angeles')
self.assertEquals(gb_time_zone, 'Europe/London')
def testRecordByAddr(self):
equal_keys = ('city', 'region_name', 'area_code', 'country_code3',
'postal_code', 'dma_code', 'country_code',
......
# -*- coding: utf-8 -*-
import unittest
import pygeoip
from tests.config import ISP_DB_PATH
class TestGeOIPISPFunctions(unittest.TestCase):
def setUp(self):
self.us_isp = 'Turner Broadcasting System'
self.us_ip = '157.166.255.18'
self.us_hostname = 'cnn.com'
self.se_isp = 'IP-Only Tele Communication AB'
self.se_ip = '213.132.112.97'
self.se_hostname = 'blocket.se'
self.gi = pygeoip.GeoIP(ISP_DB_PATH)
def testISPByAddr(self):
se_isp = self.gi.org_by_addr(self.se_ip)
us_isp = self.gi.org_by_addr(self.us_ip)
self.assertEqual(se_isp, self.se_isp)
self.assertEqual(us_isp, self.us_isp)
def testISPByName(self):
se_isp = self.gi.org_by_name(self.se_hostname)
us_isp = self.gi.org_by_name(self.us_hostname)
self.assertEqual(se_isp, self.se_isp)
self.assertEqual(us_isp, self.us_isp)
......@@ -17,14 +17,14 @@ class TestGeoIPTimeZoneFunctions(unittest.TestCase):
def testTimeZoneByAddr(self):
us_time_zone = self.gic.time_zone_by_addr(self.us_ip)
self.assertEquals(us_time_zone, 'America/Los_Angeles')
gb_time_zone = self.gic.time_zone_by_addr(self.gb_ip)
self.assertEquals(us_time_zone, 'America/Los_Angeles')
self.assertEquals(gb_time_zone, 'Europe/London')
def testTimeZoneByName(self):
us_time_zone = self.gic.time_zone_by_name(self.us_hostname)
self.assertEquals(us_time_zone, 'America/Los_Angeles')
gb_time_zone = self.gic.time_zone_by_name(self.gb_hostname)
self.assertEquals(us_time_zone, 'America/Los_Angeles')
self.assertEquals(gb_time_zone, 'Europe/London')
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment