Commit 6c7a2aec by William Tisäter

Update test to work with referenced sample databases

parent 980d8f6c
...@@ -7,9 +7,9 @@ from tests.config import ORG_DB_PATH ...@@ -7,9 +7,9 @@ from tests.config import ORG_DB_PATH
class TestGeoIPOrgFunctions(unittest.TestCase): class TestGeoIPOrgFunctions(unittest.TestCase):
def setUp(self): def setUp(self):
self.us_org = 'Google' self.us_org = 'APPLE COMPUTER'
self.us_ip = '64.233.161.99' self.us_ip = '17.172.224.47'
self.us_hostname = 'google.com' self.us_hostname = 'apple.com'
self.gb_org = 'BBC' self.gb_org = 'BBC'
self.gb_ip = '212.58.253.68' self.gb_ip = '212.58.253.68'
......
...@@ -8,10 +8,9 @@ from tests.config import REGION_DB_PATH ...@@ -8,10 +8,9 @@ from tests.config import REGION_DB_PATH
class TestGeoIPRegionFunctions(unittest.TestCase): class TestGeoIPRegionFunctions(unittest.TestCase):
def setUp(self): def setUp(self):
self.us_code = 'US' self.us_code = 'US'
self.us_hostname = 'apple.com'
self.yahoo_hostname = 'yahoo.com' self.us_ip = '17.172.224.47'
self.yahoo_ip = '209.131.36.159' self.us_region_data = {
self.yahoo_region_data = {
'region_name': 'CA', 'region_name': 'CA',
'country_code': 'US' 'country_code': 'US'
} }
...@@ -19,17 +18,17 @@ class TestGeoIPRegionFunctions(unittest.TestCase): ...@@ -19,17 +18,17 @@ class TestGeoIPRegionFunctions(unittest.TestCase):
self.gir = pygeoip.GeoIP(REGION_DB_PATH) self.gir = pygeoip.GeoIP(REGION_DB_PATH)
def testRegionByName(self): def testRegionByName(self):
region_name = self.gir.region_by_name(self.yahoo_hostname) region_name = self.gir.region_by_name(self.us_hostname)
self.assertEqual(region_name, self.yahoo_region_data) self.assertEqual(region_name, self.us_region_data)
def testRegionByAddr(self): def testRegionByAddr(self):
region_name = self.gir.region_by_addr(self.yahoo_ip) region_name = self.gir.region_by_addr(self.us_ip)
self.assertEqual(region_name, self.yahoo_region_data) self.assertEqual(region_name, self.us_region_data)
def testCountryCodeByName(self): def testCountryCodeByName(self):
us_code = self.gir.country_code_by_name(self.yahoo_hostname) us_code = self.gir.country_code_by_name(self.us_hostname)
self.assertEqual(us_code, self.us_code) self.assertEqual(us_code, self.us_code)
def testCountryCodeByAddr(self): def testCountryCodeByAddr(self):
us_code = self.gir.country_code_by_addr(self.yahoo_ip) us_code = self.gir.country_code_by_addr(self.us_ip)
self.assertEqual(us_code, self.us_code) self.assertEqual(us_code, self.us_code)
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