Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
P
pygeoip
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
OpenEdx
pygeoip
Commits
57cd341b
Commit
57cd341b
authored
Sep 25, 2012
by
William Tisäter
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add test for ISP database
parent
e52a6df3
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
37 additions
and
18 deletions
+37
-18
tests/config.py
+1
-0
tests/test_city.py
+0
-14
tests/test_isp.py
+32
-0
tests/test_tz.py
+4
-4
No files found.
tests/config.py
View file @
57cd341b
...
...
@@ -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'
)
tests/test_city.py
View file @
57cd341b
...
...
@@ -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'
,
...
...
tests/test_isp.py
0 → 100644
View file @
57cd341b
# -*- 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
)
tests/test_tz.py
View file @
57cd341b
...
...
@@ -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'
)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment